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

查看:25
本文介绍了无法安装 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

我该如何解决这个错误?

How do I fix this error?

推荐答案

升级pip如下:

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.

(注意,使用pip升级pip ie pip install --upgrade pip 也不会正确升级.它只是一个鸡-and-egg 问题.除非使用 TLS >= 1.2,否则 pip 将无法工作.)

(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.)

此详细答案中所述,这是由于最近 TLS 弃用了 pip.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天全站免登陆