'pip install' fails for every package ("Could not find a version that satisfies the requirement")

pip install <package name> is failing for every package for me. This is what I get:

Could not find a version that satisfies the requirement <package-name
(from versions: )
No matching distribution found for <package-name>

I saw similar questions on Stack Overflow, but they don't seem to be fully related to this one.

Also, this post suggests that this might happen if PyPI is down or my IP address is blacklisted. It seems both are not true for my case.

pip shows up-to-date on running pip install --upgrade pip.

363510 次浏览

PyPI 放弃了对 TLS 1.0和1.1的支持。如果您的系统没有使用更新的版本,它可能会解释您的错误。

您是否可以尝试在整个系统范围内重新安装 pip,以便将您的系统依赖关系更新到 TLS 的更新版本?

这似乎与 无法安装 Python 库有关

看看多米尼克•巴顿(Dominique Barton)的回答:

显然 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

升级点如下:

curl https://bootstrap.pypa.io/get-pip.py | python

注意: 如果不是在虚拟环境中,您可能需要使用上面的 sudo python

发生了什么:

Org 站点正在停止对 TLS 版本1.0和1.1的支持。这意味着 Mac OS X version 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 和 PyPI 的 Mac 用户:

如果您运行的是 macOS/OS X 版本10.12或更高版本,那么您应该 升级到最新的 pip (9.0.3)以连接到 Python 包 安全索引:

curl https://bootstrap.pypa.io/get-pip.py | python

我们建议你在4月8日前完成。

当在 macOS < 系统 Python 下运行时,Pip 9.0.3支持 TLSv1.2 10.13官方发布说明: https://pip.pypa.io/en/stable/news/

此外,Python 状态页面:

Completed - The rolling brownouts are finished, and TLSv1.0 and TLSv1.1 have been disabled. Apr 11, 15:37 UTC

更新 -滚动灯火管制已升级为停电,TLSv1.0和 TLSv1.1将随时被 HTTP 403拒绝。 世界协调时4月8日15:49

最后,为了避免其他安装错误,请确保在执行上述操作之后也升级了 setuptools:

pip install --upgrade setuptools