Not able to install python packages [SSL: TLSV1_ALERT_PROTOCOL_VERSION]

匿名 (未验证) 提交于 2019-12-03 02:11:02

问题:

I am trying to install python library using pip, getting ssl error.

pip version: pip 9.0.1

Any idea how to fix this error ?

回答1:

Upgrade pip as follows:

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

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

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

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.

From the Python status page:

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


For Pycharm (virtualenv) users:

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

    source ./venv/bin/activate
  2. Run upgrade

    curl https://bootstrap.pypa.io/get-pip.py | python
  3. Restart your pycharm, and check your python interpreter in Preference.



回答2:

@Anupam solution worked for me however I had to use sudo and specify the exact location of my virtual python environment

curl https://bootstrap.pypa.io/get-pip.py | sudo /Users/{your user name}/{path to python}/bin/python


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!