Python 由于环境错误,无法安装软件包:[Errno 2]

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51617284/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 19:53:02  来源:igfitidea点击:

Could not install packages due to an EnvironmentError: [Errno 2]

pythonpipinstall

提问by R. Kulebyakin

I`ve recently started having problems with pip installs. Every time I run this kind of command in Terminal, I get an error:

我最近开始遇到 pip 安装问题。每次在终端中运行此类命令时,都会出现错误:

Could not install packages due to:

由于以下原因无法安装软件包:

EnvironmentError: [Errno 2] No such file or directory: '/'me'/'me'/anaconda3/lib/python3.6/site-packages/tqdm-4.11.2.dist-info/METADATA'

EnvironmentError: [Errno 2] 没有这样的文件或目录:'/'me'/'me'/anaconda3/lib/python3.6/site-packages/tqdm-4.11.2.dist-info/METADATA'

Does anyone know what's wrong? Didn't have this issue a month ago. Please help! Just in case: the error above popped up when i wrote pip install gender-guesser.

有谁知道出了什么问题?一个月前没有这个问题。请帮忙!以防万一:当我写 pip install sex-guesser 时会弹出上面的错误。

采纳答案by angrypig298

Try to reinstall tqdm with conda. And then you can install packages with pip.

尝试使用 conda 重新安装 tqdm。然后你可以用 pip 安装包。

conda install tqdm

Wait until it done. Then you can do:

等到它完成。然后你可以这样做:

pip install gender-guesser

回答by yibo Tian

I met the same problem and this might work for you cd into the location where metadata.json exists and type this command cp metadata.json METADATA then you could do sudo pip install

我遇到了同样的问题,这可能对你有用 cd 到 metadata.json 存在的位置并输入这个命令 cp metadata.json METADATA 然后你可以做 sudo pip install

回答by Ehsan Sadr

I faced the same problem.

我遇到了同样的问题。

Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/home/myusr/.local/lib/python3.6/site-packages/pip-19.0.1.dist-info/METADATA'

由于环境错误,无法安装软件包:[Errno 2] 没有这样的文件或目录:'/home/myusr/.local/lib/python3.6/site-packages/pip-19.0.1.dist-info/METADATA'

I followed the angrypig298 solution but it didn't work for me. The first part was ok.

我遵循了angeredpig298 解决方案,但它对我不起作用。第一部分没问题。

conda install tqdm

But the second part got the same error of pip cannot find the METADATA file.

但是第二部分出现了同样的错误 pip 找不到 METADATA 文件。

pip install gender-guesser

Based on other answers, I used the find command to find the METADATA in my machine and I found it in a subdirectory.

根据其他答案,我使用 find 命令在我的机器中查找 METADATA 并在子目录中找到它。

find ~/.local/ -name  "*METADATA*" | grep pip

The METADATA was in

元数据在

/home/myuser/.local/lib/python3.6/site-packages/pip-19.0.1.dist-info/pip-19.0.1.dist-info/METADATA

I copy it to the path where the pip command is looking for it, which is one directory above it.

我将它复制到 pip 命令正在查找它的路径,这是它上面的一个目录。

/home/myuser/.local/lib/python3.4/site-packages/pip-9.0.1.dist-info/METADATA

Then the pip worked normally.

然后点子正常工作。

回答by Иван Ульченко

I use Pycharm. I have solved with problem with copy file METADATA from \AppData\Roaming\Python\Python37\site-packages\pip-19.0.1.dist-info\pip-19.0.1.dist-info to higher level \AppData\Roaming\Python\Python37\site-packages\pip-19.0.1.dist-info

我使用 Pycharm。我已经解决了从 \AppData\Roaming\Python\Python37\site-packages\pip-19.0.1.dist-info\pip-19.0.1.dist-info 到更高级别 \AppData\Roaming\ 的复制文件 METADATA 的问题Python\Python37\site-packages\pip-19.0.1.dist-info

回答by Shuai.Z

copy all the files in "/home/shuaizhang/.local/lib/python3.6/site-packages/pip-19.0.1.dist-info/pip-19.0.1.dist-info/" to the upper directory "/home/shuaizhang/.local/lib/python3.6/site-packages/pip-19.0.1.dist-info/"

将“/home/shuaizhang/.local/lib/python3.6/site-packages/pip-19.0.1.dist-info/pip-19.0.1.dist-info/”中的所有文件复制到上层目录“ /home/shuaizhang/.local/lib/python3.6/site-packages/pip-19.0.1.dist-info/"

Then, pip3 install --user --upgrade pip , solved my problem.

然后, pip3 install --user --upgrade pip ,解决了我的问题。

I hope this will help.

我希望这将有所帮助。

回答by daidai21

I find the METADATAfile in this path or this path subdirctory, then cp this file

METADATA在这个路径或者这个路径子目录中找到文件,然后cp这个文件