Python 'pip install' 对于每个包都失败(“找不到满足要求的版本”)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49748063/
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
'pip install' fails for every package ("Could not find a version that satisfies the requirement")
提问by Anupam
pip install <package name>
is failing for every package for me. This is what I get:
pip install <package name>
对我来说,每个包裹都失败了。这就是我得到的:
Could not find a version that satisfies the requirement <package-name
(from versions: )
No matching distribution found for <package-name>
I sawsimilarquestionson Stack Overflow, but they don't seem to be fully related to this one.
我在 Stack Overflow 上看到了类似的问题,但它们似乎与这个问题并不完全相关。
Also, this postsuggests that this might happen if PyPI is down or my IP address is blacklisted. It seems both are not true for my case.
此外,这篇文章表明,如果 PyPI 关闭或我的 IP 地址被列入黑名单,则可能会发生这种情况。对于我的情况,似乎两者都不正确。
pip shows up-to-date on running pip install --upgrade pip
.
pip 在运行时显示最新pip install --upgrade pip
。
回答by Anupam
Upgrade pip as follows:
升级pip如下:
curl https://bootstrap.pypa.io/get-pip.py | python
Note: You may need to use sudo python
above if not in a virtual environment.
注意:sudo python
如果不是在虚拟环境中,您可能需要使用上述内容。
What's happening:
发生了什么:
Python.org sites are stopping support for TLS versions 1.0 and 1.1. This means that Mac OS X version 10.12(Sierra) or older will not be able to use pip unless they upgrade pip as above.
Python.org 站点停止支持 TLS 1.0 和 1.1 版。这意味着Mac OS X 版本 10.12(Sierra) 或更早版本将无法使用 pip,除非他们按照上述方式升级 pip。
(Note that upgrading pip via pip install --upgrade pip
will also not upgrade it correctly. It is a chicken-and-egg issue)
(请注意,升级 pip viapip install --upgrade pip
也不会正确升级。这是鸡与蛋的问题)
Thisthread explains it (thanks to this Twitter post):
该线程对此进行了解释(感谢此 Twitter 帖子):
Mac users who use pip and PyPI:
If you are running macOS/OS X version 10.12 or older, then you ought to upgrade to the latest pip (9.0.3) to connect to the Python Package Index securely:
curl https://bootstrap.pypa.io/get-pip.py | python
and we recommend you do that by April 8th.
Pip 9.0.3 supports TLSv1.2 when running under system Python on macOS < 10.13. Official release notes: https://pip.pypa.io/en/stable/news/
使用 pip 和 PyPI 的 Mac 用户:
如果您运行的是 macOS/OS X 版本 10.12 或更早版本,那么您应该升级到最新的 pip (9.0.3) 以安全地连接到 Python Package Index:
curl https://bootstrap.pypa.io/get-pip.py | python
我们建议您在 4 月 8 日之前完成此操作。
在 macOS < 10.13 上的系统 Python 下运行时,Pip 9.0.3 支持 TLSv1.2。官方发布说明:https: //pip.pypa.io/en/stable/news/
Also, the Python status page:
此外,Python 状态页面:
Completed- The rolling brownouts are finished, and TLSv1.0 and TLSv1.1 have been disabled. Apr 11, 15:37 UTC
Update- The rolling brownouts have been upgraded to a blackout, TLSv1.0 and TLSv1.1 will be rejected with a HTTP 403 at all times. Apr 8, 15:49 UTC
已完成- 滚动停电已完成,并且已禁用 TLSv1.0 和 TLSv1.1。世界标准时间 4 月 11 日 15:37
更新- 滚动停电已升级为停电,TLSv1.0 和 TLSv1.1 将始终被 HTTP 403 拒绝。世界标准时间 4 月 8 日 15:49
Lastly, to avoid other install errors, make sure you also upgrade setuptools after doing the above:
最后,为避免其他安装错误,请确保在执行上述操作后还升级 setuptools:
pip install --upgrade setuptools
回答by Guybrush
Support for TLS 1.0 and 1.1 was dropped for PyPI. If your system does not use a more recent version, it could explain your error.
PyPI 不再支持 TLS 1.0 和 1.1。如果您的系统没有使用更新的版本,它可以解释您的错误。
Could you try reinstalling pip system-wide, to update your system dependencies to a newer version of TLS?
您能否尝试在系统范围内重新安装 pip,以将您的系统依赖项更新到较新版本的 TLS?
This seems to be related to Unable to install Python libraries
这似乎与无法安装 Python 库有关
See Dominique Barton's answer:
见多米尼克巴顿的回答:
Apparently pip is trying to access PyPI via HTTPS (which is encrypted and fine), but with an old (insecure) SSL version. Your system seems to be out of date. It might help if you update your packages.
On Debian-based systems I'd try:
apt-get update && apt-get upgrade python-pip
On Red Hat Linux-based systems:
yum update python-pip # (or python2-pip, at least on Red Hat Linux 7)
On Mac:
sudo easy_install -U pip
You can also try to update
openssl
separately.
显然 pip 正在尝试通过 HTTPS(加密且正常)访问 PyPI,但使用的是旧的(不安全的)SSL 版本。您的系统似乎已过时。如果您更新软件包可能会有所帮助。
在基于 Debian 的系统上,我会尝试:
apt-get update && apt-get upgrade python-pip
在基于 Red Hat Linux 的系统上:
yum update python-pip # (or python2-pip, at least on Red Hat Linux 7)
在 Mac 上:
sudo easy_install -U pip
您也可以尝试
openssl
单独更新。