In my project, the three following paths refer to the same location:
os.environ["TFHUB_CACHE_DIR"] = "~/my_repos/my_project/data/tfhub_cache/"
os.environ["TFHUB_CACHE_DIR"] = os.path.normpath("./data/tfhub_cache/")
os.environ["TFHUB_CACHE_DIR"] = os.path.normpath(os.path.dirname(__file__) + "../data/tfhub_cache/")
and they are used by the following code:
import tensorflow_hub as hub
embed = hub.load("https://tfhub.dev/google/universal-sentence-encoder/3")
However, the first one works correctly, while the other two, cause the following error:
Downloading pre-trained embeddings from tensorflow hub...
Traceback (most recent call last):
File "/home/my_username/.pyenv/versions/3.7.5/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/home/my_username/.pyenv/versions/3.7.5/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/my_username/my_repos/my_project/my_script.py", line 229, in <module>
embed = hub.load("https://tfhub.dev/google/universal-sentence-encoder/3")
File "/home/my_username/.local/share/virtualenvs/my_project-fkeckdfE/lib/python3.7/site-packages/tensorflow_hub/module_v2.py", line 90, in load
module_path = resolve(handle)
File "/home/my_username/.local/share/virtualenvs/my_project-fkeckdfE/lib/python3.7/site-packages/tensorflow_hub/module_v2.py", line 52, in resolve
return registry.resolver(handle)
File "/home/my_username/.local/share/virtualenvs/my_project-fkeckdfE/lib/python3.7/site-packages/tensorflow_hub/registry.py", line 42, in __call__
return impl(*args, **kwargs)
File "/home/my_username/.local/share/virtualenvs/my_project-fkeckdfE/lib/python3.7/site-packages/tensorflow_hub/compressed_module_resolver.py", line 88, in __call__
self._lock_file_timeout_sec())
File "/home/my_username/.local/share/virtualenvs/my_project-fkeckdfE/lib/python3.7/site-packages/tensorflow_hub/resolver.py", line 414, in atomic_download
tf_v1.gfile.Rename(tmp_dir, module_dir)
File "/home/my_username/.local/share/virtualenvs/my_project-fkeckdfE/lib/python3.7/site-packages/tensorflow_core/python/lib/io/file_io.py", line 504, in rename
rename_v2(oldname, newname, overwrite)
File "/home/my_username/.local/share/virtualenvs/my_project-fkeckdfE/lib/python3.7/site-packages/tensorflow_core/python/lib/io/file_io.py", line 521, in rename_v2
compat.as_bytes(src), compat.as_bytes(dst), overwrite)
tensorflow.python.framework.errors_impl.PermissionDeniedError: /home/my_username/my_repos/my_project/data/tfhub_cache/42480c3c7f42bf87d36d4c58fc4374b08dae2909.dcfe9db0c4ea456b9d3c97359f57ec1a.tmp; Permission denied
Any ideas what is causing this? (I have already chmod -R 777 on the directory!)
The script is ran using pipenv ie. pipenv run python -m scripts.my_script
Ideally, I would like the second one to work, so that other devs who have their repo in different locations are still able to just run the script.
Related
I am new to django and I tried to create a project with django-admin startproject command. The tutorial I was referring to had no errors while going through this command but I get the following error. The tutorial and I are not doing it in any virtual environment. Though this error comes, the files and folder are created in the directory I am working in, how should I solve this error?
Traceback (most recent call last):
File "C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python39\\lib\\runpy.py", line 197, in _run_module_as_main
return run_code(code, main_globals, None,
File "C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python39\\lib\\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python39\\Scripts\\django-admin.exe_main_.py", line 7, in \<module\>
File "C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\management\__init_.py", line 446, in execute_from_command_line
utility.execute()
File "C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\management\__init_.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\management\\base.py", line 402, in run_from_argv
self.execute(\*args, \*\*cmd_options)
File "C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\management\\base.py", line 448, in execute
output = self.handle(\*args, \*\*options)
File "C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\management\\commands\\startproject.py", line 21, in handle super().handle("project", project_name, target, \*\*options)
File "C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\management\\templates.py", line 225, in handle
run_formatters(\[top_dir\])
File "C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\management\\utils.py", line 165, in run_formatters
subprocess.run(
File "C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python39\\lib\\subprocess.py", line 501, in run
with Popen(\*popenargs, \*\*kwargs) as process:
File "C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python39\\lib\\subprocess.py", line 947, in __init__
self.\_execute_child(args, executable, preexec_fn, close_fds,
File "C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python39\\lib\\subprocess.py", line 1416, in \_execute_child
hp, ht, pid, tid = \_winapi.CreateProcess(executable, args,
PermissionError: \[WinError 5\] Access is denied
I've been trying to set up a virtual environment for django using pipenv. I've installed pipenv and configured the path properly. When I run the following command
pipenv --version
I get
pipenv, version 2022.9.8
Which implies that pipenv is working.
But when I attempt to install django with the following command
pipenv install django
I get the following error.
C:\Users\Saifia>pipenv install django
Traceback (most recent call last):
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 620, in parse_executable
result_version = get_python_version(path)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\utils.py", line 97, in get_python_version
c = subprocess.Popen(version_cmd, **subprocess_kwargs)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\pipenv.exe\__main__.py", line 7, in <module>
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\cli\options.py", line 57, in main
return super().main(*args, **kwargs, windows_expand_args=False)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 1053, in main
rv = self.invoke(ctx)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\cli\command.py", line 236, in install
do_install(
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\core.py", line 2056, in do_install
ensure_project(
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\core.py", line 526, in ensure_project
ensure_virtualenv(
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\core.py", line 447, in ensure_virtualenv
python = ensure_python(project, three=three, python=python)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\core.py", line 336, in ensure_python
path_to_python = find_a_system_python(python)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\core.py", line 302, in find_a_system_python
return next(iter(finder.find_all_python_versions()), None)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 307, in find_all_python_versions
python_version_dict = getattr(self.system_path, "python_version_dict", {})
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 115, in system_path
self._system_path = self.create_system_path()
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 77, in create_system_path
return pyfinder_path.SystemPath.create(
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 696, in create
instance = instance._run_setup()
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 247, in _run_setup
new_instance = new_instance._setup_windows()
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 425, in _setup_windows
windows_finder = WindowsFinder.create()
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\windows.py", line 149, in create
return cls()
File "<attrs generated init pythonfinder.models.windows.WindowsFinder>", line 13, in __init__
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\windows.py", line 116, in get_versions
versions[py_version.version_tuple[:5]] = base_dir
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 367, in __getattribute__
result = super(PythonVersion, self).__getattribute__(key)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 432, in version_tuple
self.patch,
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 377, in __getattribute__
instance_dict = self.parse_executable(executable)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 622, in parse_executable
raise ValueError("Not a valid python path: %r" % path)
ValueError: Not a valid python path: 'C:/Users/Saifia/anaconda3/Scripts/python.exe'
I've been trying to figure this out the whole day and have tried various things but I'm new this and I can't figure out my mistake.
Any help will be greatly appreciated!
I was using virtualenv for virtualization and had to use pipenv to follow a tutorial and could not get pipenv to work. I had to uninstall virtualenv and pipenv and reinstall pipenv for it to work. I am still using pipenv but I do not like it virtualenv works better for me.
I think that the key to your problem is the last message in the traceback:
"ValueError: Not a valid python path: 'C:/Users/Saifia/anaconda3/Scripts/python.exe'"
Check and see if this file exists at this location.
If not, your default python version isn't set correctly in pipenv.
Deactivate any virtual environment and check your python version before you install pipenv.
i had installed it through :
pip install remo
then i tried to initialize it through :
python -m remo_app init
but an error is showing of installing postgres even after installing it manually
i also tried with different versions but in vain
the error was:
C:\Users\Admin>python -m remo_app init
===============================================
((
(>’:’) Remo: v0.4.5
Python: 3.8.1, Windows-10-10.0.18362-SP0
Initiailizing Remo:
This will download and install the following packages as needed:
vips
postgres
scoop
git
unzip
aria2
Do you want to continue? [Y/n]: y
[-] Installing vips lib
[-] Installing postgres
Traceback (most recent call last):
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\runpy.py”, line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\runpy.py”, line 86, in run_code
exec(code, run_globals)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\remo_app_main.py", line 3, in
app()
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\typer\main.py”, line 211, in call
return get_command(self)()
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py”, line 829, in call
return self.main(*args, **kwargs)
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py”, line 782, in main
rv = self.invoke(ctx)
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py”, line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py”, line 610, in invoke
return callback(*args, **kwargs)
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\typer\main.py”, line 494, in wrapper
return callback(**use_params) # type: ignore
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\remo_app\cmd\cmd.py”, line 55, in init
db_config = installer.install(postgres=postgres.get_instance())
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\remo_app\cmd\installer.py”, line 333, in install
return postgres.install()
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\remo_app\cmd\installer.py”, line 212, in install
if not self._is_installed():
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\remo_app\cmd\postgres.py”, line 55, in _is_installed
self._set_env_vars()
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\remo_app\cmd\postgres.py”, line 91, in _set_env_vars
if not os.path.exists(os.getenv(‘PGDATA’)):
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\genericpath.py”, line 19, in exists
os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
This is an issue with Remo. Take a look here:
https://support.remo.ai/
and see there are two threads about installation problems on Windows.
I managed to break az, by using CTRL-C after the command "az login". Now, all I can get is this message :
Traceback (most recent call last):
File "runpy.py", line 193, in _run_module_as_main
File "runpy.py", line 85, in _run_code
File "C:\Users\trdai\AppData\Local\Temp\pip-install-8jgnm5o1\azure-cli\azure\cli\__main__.py", line 32, in <module>
File "C:\Users\trdai\AppData\Local\Temp\pip-install-8jgnm5o1\azure-cli-core\azure\cli\core\__init__.py", line 509, in get_default_cli
File "C:\Users\trdai\AppData\Local\Temp\pip-install-8jgnm5o1\azure-cli-core\azure\cli\core\__init__.py", line 52, in __init__
File "C:\Users\trdai\AppData\Local\Temp\pip-install-8jgnm5o1\azure-cli-core\azure\cli\core\_session.py", line 40, in load
File "json\__init__.py", line 299, in load
File "json\__init__.py", line 354, in loads
File "json\decoder.py", line 339, in decode
File "json\decoder.py", line 357, in raw_decode
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The command I use to get this message
Any idea on how to clean the cache? I already tried to reinstall, to repair, to remove and reinstall again, with no success.
Thanks in advance.
In this case cleaning the temp folder (/home/user/.azure) solved the problem
Downloading spacy "en" model by following command
python -m spacy download en
throws URL error.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/spacy/__main__.py", line 31, in <module>
plac.call(commands[command], sys.argv[1:])
File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/plac_core.py", line 328, in call
cmd, result = parser.consume(arglist)
File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/plac_core.py", line 207, in consume
return cmd, self.func(*(args + varargs + extraopts), **kwargs)
File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/spacy/cli/download.py", line 30, in download
shortcuts = get_json(about.__shortcuts__, "available shortcuts")
File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/spacy/cli/download.py", line 55, in get_json
data = url_read(url)
File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/spacy/compat.py", line 82, in url_read
file_ = url_open(url)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>
Then I tried installing Install Certificates.command but it didn't solved the problem.
Specifications:
OS: Mac High Sierra
ENV: venv (python virtual environment)
The problem might be related to this issue and PR, and the fact that unlike requests, urllib doesn't check for certificates in extra places.
After some back and forth, the upcoming version of spaCy will revert this change and go back to using requests – dropping the dependency just wasn't worth the hassle. In the meantime, you can always download and install the models manually by pointing pip install to the direct URL. See this section in the docs for details.