无法安装Python库

nis*_*ish 13 python pip python-2.7

我无法安装任何Python库.我正在使用pip 9.0.1python 2.7.我收到以下错误:

EN-NishantS:~ 8417$ pip install presto-python-client
Collecting presto-python-client
  Could not find a version that satisfies the requirement presto-python-client (from versions: )
No matching distribution found for presto-python-client
Run Code Online (Sandbox Code Playgroud)

在运行时,pip install -vvv我得到以下内容:

Collecting presto-python-client
  1 location(s) to search for versions of presto-python-client:
  * https://pypi.python.org/simple/presto-python-client/
  Getting page https://pypi.python.org/simple/presto-python-client/
  Looking up "https://pypi.python.org/simple/presto-python-client/" in the cache
  No cache entry available
  Starting new HTTPS connection (1): pypi.python.org
  "GET /simple/presto-python-client/ HTTP/1.1" 403 170
  Status code 403 not in [200, 203, 300, 301]
  Could not fetch URL https://pypi.python.org/simple/presto-python-client/: 403 Client Error: TLSv1.2+ is required for url: https://pypi.python.org/simple/presto-python-client/ - skipping
  Could not find a version that satisfies the requirement presto-python-client (from versions: )
Cleaning up...
No matching distribution found for presto-python-client
Exception information:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 324, in run
    requirement_set.prepare_files(finder)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/index.py", line 514, in find_requirement
    'No matching distribution found for %s' % req
DistributionNotFound: No matching distribution found for presto-python-client
Looking up "https://pypi.python.org/pypi/pip/json" in the cache
No cache entry available
Starting new HTTPS connection (1): pypi.python.org
"GET /pypi/pip/json HTTP/1.1" 403 170
Status code 403 not in [200, 203, 300, 301]
There was an error checking the latest version of pip
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/outdated.py", line 128, in pip_version_check
    resp.raise_for_status()
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/models.py", line 862, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
HTTPError: 403 Client Error: TLSv1.2+ is required for url: https://pypi.python.org/pypi/pip/json
Run Code Online (Sandbox Code Playgroud)

Esi*_*ngs 9

在Mac上你可以做到 sudo curl https://bootstrap.pypa.io/get-pip.py | python


biz*_*zyb 6

我今天遇到了同样的问题,试图安装Django.

我刚刚重新安装了pip.从https://pip.pypa.io/en/stable/installing/获取get-pip.py,然后python get-pip.py在你的virtualenv中运行.这应该覆盖现有安装并更新SSL证书.


小智 5

同样在macOS v10.12 (Sierra)上的同事通过运行brew install python@2然后覆盖以前的版本来解决了这个问题。Python 网站上的版本似乎没有捆绑正确的 OpenSSL 版本。

我认为有人也直接向 Python 提交了一个错误:OS X system OpenSSL deprecated - installer should build local libssl


Anu*_*pam 5

看来这个问题在Stack Overflow上引起了很多问题,这些问题是关于各种软件包没有使用来安装的pip install package-name。因此,我想我将从此处复制答案,以使该问题更清晰:

解决方案是将pip升级到最新版本。

但是,通过升级点子pip install --upgrade pip可能无法正确升级(即使不是,它也会显示它是最新的)。

因此(例如,对于Mac用户),我们需要按以下方式升级点子:

curl https://bootstrap.pypa.io/get-pip.py | python
Run Code Online (Sandbox Code Playgroud)

发生了什么:

Python.org网站正在停止对TLS版本1.0和1.1的支持。这意味着Mac OS X版本10.12(Sierra)或更早版本将无法使用pip,除非它们如上所述升级了pip。

线程对此进行了解释(感谢此Twitter帖子):

使用pip和PyPI的Mac用户:

如果您运行的是macOS / OS X版本10.12或更旧版本,则应升级到最新的点(9.0.3)以安全地连接到Python软件包索引:

curl https://bootstrap.pypa.io/get-pip.py | python
Run Code Online (Sandbox Code Playgroud)

我们建议您在4月8日之前这样做。

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

另外,Python状态页

已完成 -滚动式电源不足已完成,并且TLSv1.0和TLSv1.1已被禁用。世界标准时间4月11日15:37

更新 -滚动停电已升级为停电,TLSv1.0和TLSv1.1将始终被HTTP 403拒绝。世界标准时间4月8日15:49

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

pip install --upgrade setuptools
Run Code Online (Sandbox Code Playgroud)