Launching Tensorboard: bad interpreter: No such file or directory - tensorflow

I am unable to run tensorboard, and get the message:
bad interpreter: No such file or directory
Steps to reproduce:
Installed TF on Ubuntu, using a virtenv, and pip as per instructions install instructions
Confirmed TF was correctly installed by running the mnist example. Output was as expected
Attempted to run tensorboard using:
tensorboard --logdir=/tmp/tensorflow/mnist/logs/mnist_with_summaries/
Checked that this location does contain the summary files within the "test" and "train" directories
Command and error:
(tensorflow_1_4_0) js#pchome01:~$ tensorboard --logdir=/tmp/tensorflow/mnist/logs/mnist_with_summaries/
bash: /home/js/tensorflow_1_4_0/bin/tensorboard: /home/js/tensorflow_1_3/bin/python3: bad interpreter: No such file or directory
In my virtenv folder for tensorflow_1_4_0, a tensorboard script exists:
#!/home/js/tensorflow_1_3/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from tensorboard.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
When I run the following from the terminal, no errors are reported:
from tensorboard.main import main
Thank you

Just spotted my silly mistake and posting the resolution in case others encounter this.
The meaning of the error message is that the interpreter of the code (in this case python3) cannot be found.
The first line of the tensorboard script:
#!/home/js/tensorflow_1_3/bin/python3
This tells the compiler to look for python3 at this location, however this path is incorrect and the virtual environment is actually called tensorflow_1_4_0.
Therefore changing this line to the following fixed the error:
#!/home/js/tensorflow_1_4_0/bin/python3

Related

Unable to install tiktoken from PyPI

I am working on some OpenAI's API integrations. I am facing an issue while installing the tiktoken (a fast BPE tokeniser for use with OpenAI's models).
When I try to run on my macbook machine:
pip3 install tiktoken -v
It throws the following error (Using pip 22.3.1, error truncated because very long):
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
Perhaps try: xcode-select --install
*********************************************************************************
error: command '/usr/bin/clang' failed with exit code 1
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
full command: /Users/gianlucatrentin/gptenv/bin/python3 -u -c '
exec(compile('"'"''"'"''"'"'
# This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
#
# - It imports setuptools before invoking setup.py, to enable projects that directly
# import from `distutils.core` to work with newer packaging standards.
# - It provides a clear error message when setuptools is not installed.
# - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
# setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
# manifest_maker: standard file '"'"'-c'"'"' not found".
# - It generates a shim setup.py, for handling setup.cfg-only projects.
import os, sys, tokenize
try:
import setuptools
except ImportError as error:
print(
"ERROR: Can not execute `setup.py` since setuptools is not available in "
"the build environment.",
file=sys.stderr,
)
sys.exit(1)
__file__ = %r
sys.argv[0] = __file__
if os.path.exists(__file__):
filename = __file__
with tokenize.open(__file__) as f:
setup_py_code = f.read()
else:
filename = "<auto-generated setuptools caller>"
setup_py_code = "from setuptools import setup; setup()"
exec(compile(setup_py_code, filename, "exec"))
'"'"''"'"''"'"' % ('"'"'/private/var/folders/sc/gl1552412gb0lg7_x33zrgj00000gn/T/pip-install-l7tec_bv/lxml_b78f1cdebea441d2b840e6957fabe83a/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' bdist_wheel -d /private/var/folders/sc/gl1552412gb0lg7_x33zrgj00000gn/T/pip-wheel-sd9x1ng7
cwd: /private/var/folders/sc/gl1552412gb0lg7_x33zrgj00000gn/T/pip-install-l7tec_bv/lxml_b78f1cdebea441d2b840e6957fabe83a/
Building wheel for lxml (setup.py) ... error
ERROR: Failed building wheel for lxml
Running setup.py clean for lxml
Running command python setup.py clean
Building lxml version 4.9.2.
Building without Cython.
Building against libxml2 2.9.13 and libxslt 1.1.35
running clean
removing 'build/temp.macosx-10.9-universal2-cpython-310' (and everything under it)
removing 'build/lib.macosx-10.9-universal2-cpython-310' (and everything under it)
'build/bdist.macosx-10.9-universal2' does not exist -- can't clean it
'build/scripts-3.10' does not exist -- can't clean it
removing 'build'
...
× Running setup.py install for pycryptodomex did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
full command: /Users/gianlucatrentin/gptenv/bin/python3 -u -c '
exec(compile('"'"''"'"''"'"'
# This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
#
# - It imports setuptools before invoking setup.py, to enable projects that directly
# import from `distutils.core` to work with newer packaging standards.
# - It provides a clear error message when setuptools is not installed.
# - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
# setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
# manifest_maker: standard file '"'"'-c'"'"' not found".
# - It generates a shim setup.py, for handling setup.cfg-only projects.
import os, sys, tokenize
try:
import setuptools
except ImportError as error:
print(
"ERROR: Can not execute `setup.py` since setuptools is not available in "
"the build environment.",
file=sys.stderr,
)
sys.exit(1)
__file__ = %r
sys.argv[0] = __file__
if os.path.exists(__file__):
filename = __file__
with tokenize.open(__file__) as f:
setup_py_code = f.read()
else:
filename = "<auto-generated setuptools caller>"
setup_py_code = "from setuptools import setup; setup()"
exec(compile(setup_py_code, filename, "exec"))
'"'"''"'"''"'"' % ('"'"'/private/var/folders/sc/gl1552412gb0lg7_x33zrgj00000gn/T/pip-install-l7tec_bv/pycryptodomex_7192f9e9e3b34b15b1960598d9d7eb02/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' install --record /private/var/folders/sc/gl1552412gb0lg7_x33zrgj00000gn/T/pip-record-n_aypwf1/install-record.txt --single-version-externally-managed --compile --install-headers /Users/gianlucatrentin/gptenv/include/site/python3.10/pycryptodomex
cwd: /private/var/folders/sc/gl1552412gb0lg7_x33zrgj00000gn/T/pip-install-l7tec_bv/pycryptodomex_7192f9e9e3b34b15b1960598d9d7eb02/
Running setup.py install for pycryptodomex ... error
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> pycryptodomex
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
I try to upgrade all the mentione libraries but couldn't make it work.
Do you have suggestions on how to solve this installing issue?

PermissionError with spacy train on Windows

This question is same as asked in this GitHub discussion.
I am using the latest version (3.3.0).
This has also been discussed before: this previous discussion.
While training, I am facing errors like PermissionError: [WinError 5] Access is denied: 'output\\model-best\\ner'.
I am using the following line as mentioned in the earlier discussion (link above)
python -m spacy init config config.cfg --lang en --pipeline ner --force
(python -m spacy init fill-config base_config.cfg config.cfg also doesn't work)
Then I am converting some CoNLL 2003 data to spacy format (using spacy convert ... -c ner).
Then trying to train using
python -m spacy train ./config.cfg --output ./output --paths.train <path to train.spacy> --paths.dev <path to valid.spacy>
I am getting the following error:
...lots of lines...
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 620, in _rmtree_unsafe
os.rmdir(path)
PermissionError: [WinError 5] Access is denied: 'output\\model-best\\ner'
As mentioned in the earlier discussion, I have already tried running
import spacy, shutil
nlp = spacy.blank("en")
print("saving model")
nlp.to_disk("check-serialize")
print("deleting model")
shutil.rmtree("check-serialize")
print("delete finished")
and this works fine.
Using Windows Terminal in admin mode gives similar errors.
The config file can be found at the 1st link above.

Cannot import name 'model_lib_v2' from 'object_detection'

I'm trying to train TF2 for object detection. When I run model_main_tf2.py, I get the following error:
Traceback (most recent call last):
File "C:\Python_venv\trained_models\model_main_tf2.py", line 32, in <module>
from object_detection import model_lib_v2
ImportError: cannot import name 'model_lib_v2' from 'object_detection' (c:\Python_venv\tensorflow\lib\site-packages\object_detection\__init__.py)
How do I install model_lib_v2?
I tried reinstalling TF and reinstalling TensorFlow-object-detection-API but no luck. I went all over the internet looking for answers.
I found:
https://github.com/tensorflow/models/issues/7920
But they don't say how to install model_lib_v2
Unfortunately I cannot use TF1, the goal is to use TF2.
see https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2.md
git clone https://github.com/tensorflow/models.git
## Python Package Installation
cd models/research
### Compile protos.
protoc object_detection/protos/*.proto --python_out=.
### Install TensorFlow Object Detection API.
cp object_detection/packages/tf2/setup.py .
python3 -m pip install --user --use-feature=2020-resolver .
You should be able to just go to line 32 in "C:\Python_venv\trained_models\model_main_tf2.py" and remove "from object_detection", since you are already inside the package.
replace:
"from object_detection import model_lib_v2"
by:
"import model_lib_v2"

Orange Error During Installing Text Add On

I am trying to install the Text add-on (version 0.7.3) for Orange (version 3.23) on my Win10, but I am getting the following error during the building "ufal_udpipe":
Command failed: python python -m pip install --constraint 'C:\Users\Jakub\AppData\Local\Temp\tmpb4fneogu.txt' Orange3-Text exited with non zero status.
ERROR: Command errored out with exit status 1: 'C:\Users\Jakub\AppData\Local\Orange\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Jakub\\AppData\\Local\\Temp\\pip-install-r71cit89\\ufal.udpipe\\setup.py'"'"'; __file__='"'"'C:\\Users\\Jakub\\AppData\\Local\\Temp\\pip-install-r71cit89\\ufal.udpipe\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Jakub\AppData\Local\Temp\pip-record-gtt8e801\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
I also tried to install Microsoft Visual C++, because it´s required in the log, but the problem is the same after the installation.
I tried to install add-on throught the Anaconda Prompt:
conda config --add channels conda-forge
conda install orange3-text
This process failed, because:
Preparing transaction: done
Verifying transaction: done
Executing transaction: failed
ERROR conda.core.link:_execute(502): An error occurred while installing package 'conda-forge::commonmark-0.9.0-py_0'.
CondaError: Cannot link a source that does not exist. C:\Users\Jakub\Miniconda3\Scripts\conda.exe
Running `conda clean --packages` may resolve your problem.
Attempting to roll back.
Rolling back transaction: done
The result of conda clean command is following:
Traceback (most recent call last):
File "C:\Users\Jakub\Miniconda3\Scripts\conda-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\cli\main.py", line 112, in main
from ..exceptions import conda_exception_handler
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\exceptions.py", line 18, in <module>
from .common.io import timeout
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\common\io.py", line 28, in <module>
from .._vendor.tqdm import tqdm
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\_vendor\tqdm\__init__.py", line 8, in <module>
from ._tqdm import tqdm
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\_vendor\tqdm\_tqdm.py", line 13, in <module>
from ._utils import _supports_unicode, _environ_cols_wrapper, _range, _unich, \
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\_vendor\tqdm\_utils.py", line 31, in <module>
colorama.init()
AttributeError: module 'colorama' has no attribute 'init'
Reinstall of Orange and Anaconda didn´t help.
Full extract of logs is here: Google Disk
Thank you for your help!
Jakub
I encountered just the first line of your error. I checked if I had python and anaconda installed properly or not (and I had). I then kept trying to install and in the 4th go it installed without an issue- now my guess is maybe network issues caused the error to occur.
Another thing suggested to me by their support was- "Yes, we are aware of the issue. Somewhere in the process we accidentally disabled the necessary setting. Go to Options - Settings, find the Add-ons tab and select 'Install add-ons with conda'. This should install Text successfully."
Okay, so I found the issue fix (at least for me - comment if it works for you).
How to fix it:
Download Colorama
Copy the "Colorama" from the download then replace the folder named "colorama" in C:\Program Files\Anaconda3\Lib\site-packages
I suspect this issue occurs because of (issue 8842)

python -m pip install urllib having systax error while installation of this module

here see what happened
when I run the above command cmd I get an error while installing. As you can see in the above image.
s.connect((base64.b64decode(rip),17620)
I get syntax error: invalid token in line 191
and it is also giving me problems on some other modules also.
s.connect((base64.b64decode(rip),17620)
I get syntax error: invalid token in line 191
(I ran into this myself using jupyter notebook)
As you are using python 3 you don't need to install URL lib as it is part of core https://github.com/python/cpython/tree/3.6/Lib/urllib/
It's submodules are restructured so you need to change python 2 code like
import urllib
...
urllib.urlopen
into
import urllib.request
...
urllib.request.urlopen