Python 由于环境错误,无法安装软件包:[Errno 2] 没有这样的文件或目录 \\METADATA
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/54778630/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory \\METADATA
提问by Adrian Nesta
I relatively new to coding so I am not (yet) running virtual environments. Rather, I am just downloading packages with pip straight to my pc to run python 3.7 in atom.
我对编码比较陌生,所以我(还)还没有运行虚拟环境。相反,我只是将带有 pip 的软件包直接下载到我的电脑上,以便在 atom 中运行 python 3.7。
When I tried to use pip the other day to install the scrapy package like so -m pip install --user scrapy
当我前几天尝试使用 pip 像这样安装scrapy包时 -m pip install --user scrapy
I got this error: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\users\\adrian\\appdata\\roaming\\python\\python37\\site-packages\\pip-19.0.1.dist-info\\METADATA'
我收到此错误: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\users\\adrian\\appdata\\roaming\\python\\python37\\site-packages\\pip-19.0.1.dist-info\\METADATA'
Most of the other answers I have seen on related errors had people use conda to install some type of fix I think? When I tried to use conda to execute one of the fixes I recieved a CondaHTTPError: SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/free/noarch/repodata.json.bz2 (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available.
我在相关错误中看到的大多数其他答案是否有人使用 conda 来安装我认为的某种类型的修复程序?当我尝试使用 conda 执行其中一项修复时,我收到了 CondaHTTPError:SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/free/noarch/repodata.json.bz2 (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available.
Any direction would be heartily appreciated :-)
任何方向将不胜感激:-)
回答by Filip Savic
TL;DR:
特尔;博士:
Problem: Long install path
问题:安装路径长
Solution: Install the desired python package (in my case tensorflow) in the folder which has a shorter path (for example C:/my_py_packages/some_package
) or set the registry value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled
to 1
as mentioned here.
解决方案:在路径较短的文件夹(例如C:/my_py_packages/some_package
)中安装所需的python包(在我的情况下为tensorflow )或将注册表值HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled
设置1
为此处提到的。
Original answer:I got here by having this kind of error when I tried installing tensorflow
library. My error was the following:
原始答案:我在尝试安装tensorflow
库时遇到这种错误。我的错误如下:
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\moj ifajlovi\faks\11master\1semestar\siap-sistemizaistrazivanjeianalizupodataka_(datamining)\projek at\rad\venvs\siap_venv\Lib\site-packages\tensorflow_estimator\python\estimator\canned\line ar_optimizer\python\utils\__pycache__\sharded_mutable_dense_hashtable.cpython-37.pyc'
由于环境错误,无法安装软件包:[Errno 2] 没有这样的文件或目录:'c:\moj ifajlovi\faks\11master\1semestar\siap-sistemizaistrazivanjeianalizupodataka_(datamining)\projek at\rad\venvs\siap_venv\Lib\站点包\tensorflow_estimator\python\estimator\canned\line ar_optimizer\python\utils\__pycache__\sharded_mutable_dense_hashtable.cpython-37.pyc'
So, there was no sharded_mutable_dense_hashtable.cpython-37.pyc
file in the __pycache__
directory. But, sharded_mutable_dense_hashtable.cpython-37.pyc
file was in the utils
directory (which is the parent directory of __pycache__
directory).
所以,目录中没有sharded_mutable_dense_hashtable.cpython-37.pyc
文件__pycache__
。但是,sharded_mutable_dense_hashtable.cpython-37.pyc
文件在utils
目录中(这是目录的父__pycache__
目录)。
That's why I tried manually copying the sharded_mutable_dense_hashtable.cpython-37.pyc
file in the __pycache__
directory. When I tried that, I had a copy error which stated that the path was too long, so it couldn't put the file in the directory.
这就是为什么我尝试手动复制sharded_mutable_dense_hashtable.cpython-37.pyc
目录中的__pycache__
文件。当我尝试这样做时,出现复制错误,指出路径太长,因此无法将文件放入目录中。
So, the solution:
所以,解决方案:
Install the desired python package (in my case tensorflow) in the folder which has a shorter path (for example C:/my_py_packages/some_package
) or set the registry value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled
to 1
as mentioned here.
在具有较短路径(例如C:/my_py_packages/some_package
)的文件夹中安装所需的python包(在我的情况下为tensorflow )或将注册表值HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled
设置1
为此处提到的。
回答by Justin Cooksey
I had the same error trying to install Jupyter, with the path under my user profile ending with \site-packages\pip-19.0.1.dist-info\METADATA
我在尝试安装 Jupyter 时遇到了同样的错误,我的用户配置文件下的路径以 \site-packages\pip-19.0.1.dist-info\METADATA 结尾
When I checked that location it didnt contain METADATA, but another folder named pip-19.0.1.dist-info That folder had several files in it including METADATA
当我检查该位置时,它不包含 METADATA,而是另一个名为 pip-19.0.1.dist-info 的文件夹该文件夹中有几个文件,包括 METADATA
I moved those files back the directory so it matched the path listed in the error and then upgraded pip (Under an administrator account)
我将这些文件移回目录,使其与错误中列出的路径匹配,然后升级 pip(在管理员帐户下)
pip3 install --upgrade pip
pip3 install --upgrade pip
Which worked and updated pip
哪个有效并更新了 pip
I could then run the Jupyter install and got no error
然后我可以运行 Jupyter 安装并且没有错误
回答by dayudodo
回答by Huey Mataruse
I experienced this error while I was installing Apache Superset on Windows 10. The problem is with the MAX_PATHlength.
我在 Windows 10 上安装 Apache Superset 时遇到了这个错误。问题在于MAX_PATH长度。
pip
on windows is not able to handle those long installation path url so it usually results in errors.
pip
在 Windows 上无法处理那些长安装路径 url,因此通常会导致错误。
Solution:What worked for me was to Uninstallpython then ReInstalledit again but this time after a successful reinstallation, you HAVE TO DISABLE THE PATH LENGTH LIMIT
解决方案:对我有用的是卸载python 然后重新安装它,但这次成功重新安装后,你必须禁用路径长度限制
回答by EsC369
So the above so called solution didn't make much sense to me.. Sorter path?? Anyways, what worked for me, is this.
所以上面所谓的解决方案对我来说没有多大意义.. Sorter path?? 无论如何,对我有用的是这个。
My error:
我的错误:
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\users\MYUSERNAME\appdata\roaming\python\python37\site-packages\pip-19.0.1.dist-info\METADATA'
So I went to the directory:
所以我去了目录:
c:\users\MYUSERNAME\appdata\roaming\python\python37\site-packages\pip-19.0.1.dist-info\
Indeed there was no MetaData file. However there was a folder called 19.0.1.dist-info
, inside that, has the meta data file. Just move it outside into the above directory, and BAM! Problem fixed.
确实没有元数据文件。但是有一个名为 的文件夹19.0.1.dist-info
,里面有元数据文件。只需将它移到上面的目录中,BAM!问题已解决。
回答by Brad123
You might not like this answer, but what worked for me was to find the file: "METADATA" from a folder with an older version and copy it into the newer one. This is not a solution I'm confident in, but pip at least finished installing.
您可能不喜欢这个答案,但对我有用的是从旧版本的文件夹中找到文件:“METADATA”并将其复制到新版本中。这不是我有信心的解决方案,但 pip 至少完成了安装。