无法安装Python软件包[SSL:TLSV1_ALERT_PROTOCOL_VERSION] [英] Not able to install Python packages [SSL: TLSV1_ALERT_PROTOCOL_VERSION]

查看:100
本文介绍了无法安装Python软件包[SSL:TLSV1_ALERT_PROTOCOL_VERSION]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用pip安装Python库,但遇到SSL错误:

I am trying to install a Python library using pip, getting an SSL error:

~/projects/base  pre-master±  pip install xdict

Collecting xdict
  Could not fetch URL https://pypi.python.org/simple/xdict/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping
  Could not find a version that satisfies the requirement xdict (from versions: )
No matching distribution found for xdict

pip版本:pip 9.0.1

pip version: pip 9.0.1

如何解决此错误?

推荐答案

升级点如下:

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

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

Note: You may need to use sudo python above if not in a virtual environment.

(请注意,使用pippip install --upgrade pip升级pip也不会正确升级.这只是一个鸡与蛋的问题.pip除非使用TLS> = 1.2,否则将无法工作.)

(Note that upgrading pip using pip i.e pip install --upgrade pip will also not upgrade it correctly. It's just a chicken-and-egg issue. pip won't work unless using TLS >= 1.2.)

此详细答案中所述,这是由于最近对pip的TLS弃用. Python.org网站具有停止对TLS版本1.0和1.1的支持.

As mentioned in this detailed answer, this is due to the recent TLS deprecation for pip. Python.org sites have stopped support for TLS versions 1.0 and 1.1.

在Python状态页上:

From the Python status page:

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

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


对于PyCharm(virtualenv)用户:

  1. 使用shell运行虚拟环境. (将"./venv/bin/activate"替换为您自己的路径)

  1. Run virtual environment with shell. (replace "./venv/bin/activate" to your own path)

source ./venv/bin/activate

  • 运行升级

  • Run upgrade

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

  • 重新启动您的PyCharm实例,并在 Preference 中检查您的Python解释器.

  • Restart your PyCharm instance, and check your Python interpreter in Preference.

    这篇关于无法安装Python软件包[SSL:TLSV1_ALERT_PROTOCOL_VERSION]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆