无法安装Python库

无法安装Python库,python,python-2.7,pip,Python,Python 2.7,Pip,我无法安装任何Python库。我使用的是pip9.0.1和python2.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 distribu

我无法安装任何Python库。我使用的是
pip9.0.1
python2.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
使用
pip安装-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

您对PyPI的HTTP请求失败,出现HTTP 403(禁止)错误:

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

一位同事(Sierra)刚刚通过运行
brew安装解决了这个问题python@2
然后覆盖以前的版本。Python网站上的版本似乎没有绑定正确的OpenSSL版本


我想也有人直接向Python提交了一个bug:

我今天在安装Django时遇到了同样的问题


我刚刚重新安装了pip。从获取Get-pip.py,然后在您的virtualenv中运行
python Get-pip.py
。这将覆盖现有安装并更新SSL证书。

我遇到了类似的问题

问题出在与系统Python安装相链接的旧版本OpenSSL中

因此,我已从系统中卸载了所有Python发行版,并使用
brew安装安装了最后一个Python实现python@2

您可以像这样检查链接到Python的OpenSSL版本:

Python 2.7.14 (default, Mar 22 2018, 15:04:47)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.0.2o  27 Mar 2018'

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

这个问题似乎在StackOverflow上产生了很多问题,关于没有使用
pip安装包名安装的各种包。所以我想我会把我的答案抄过来,以便更清楚地了解这个问题:

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

但是,通过
pip安装升级pip——升级pip
可能无法正确升级它(即使它不是最新的,它也会显示它是最新的)

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

curl https://bootstrap.pypa.io/get-pip.py | python
发生了什么: org网站正在停止对TLS版本1.0和1.1的支持。这意味着(Sierra)或更老版本将无法使用pip,除非他们按照上述方式升级pip

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

使用pip和PyPI的Mac用户:

如果您运行的是macOS/OSX版本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. 官方发行说明:

此外,委员会:

已完成-滚动限电已完成,TLSv1.0和TLSv1.1已禁用。4月11日15:37 UTC

更新-滚动限电已升级为断电,TLSv1.0和TLSv1.1将始终被HTTP 403拒绝。 4月8日15:49 UTC

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

pip install --upgrade setuptools

我使用
sudopip3安装--升级pip


要升级High Sierra 2.7版,我必须使用
sudo pip2安装--升级pip

这可能是根本原因:
TLSv1.2+是url所必需的:https://pypi.python.org/
。(TLS是https中的s)。你的系统有多旧?@VPfB:我在用MacOSSierra@nish对不起,我看到消息太晚了。您是否通过brew安装了pip?您可能希望通过brew进行更新,或者尝试“sudo easy_install-U pip”进行更新?@nish Sierra并不老,TLS v1.2支持应该没有问题,除非安装或配置不正确。我最近遇到了相同的错误。通过如下方式安装pip得到解决:
curlhttps://bootstrap.pypa.io/get-pip.py |python
。看,这对我不起作用。我有mac 10.10.5。我收到权限错误[Errno 13]权限被拒绝:'/Library/Python/2.7/site-packages/pip-7.1.2.dist-info/DESCRIPTION.rst'谢谢发布此消息!!你能描述一下你是如何删除所有版本的Python的吗?这个问题快把我逼疯了。@juliushibert我是用一种简单愚蠢的方式做的。只需列出终端中的所有python命令(python、python2等),检查它是否是文件或链接,然后将它们全部rm化。谢谢,我已经寻找这个解决方案好几个小时了
pip install --upgrade setuptools