Not able to install Python packages [SSL: TLSV1_ALERT_PROTOCOL_VERSION]

前端 未结 17 2022
一整个雨季
一整个雨季 2020-11-21 13:16

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

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

Collecting xdict
  Co         


        
相关标签:
17条回答
  • 2020-11-21 13:50

    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. It's just a chicken-and-egg issue. pip won't 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 instance, and check your Python interpreter in Preference.

    0 讨论(0)
  • 2020-11-21 13:50

    This worked for me. Add sudo before python

    curl https://bootstrap.pypa.io/get-pip.py |sudo python
    
    0 讨论(0)
  • 2020-11-21 13:52

    This worked for me, I installed latest version of pip and then installed the library (ciscoconfparse).

    Upgrading pip:

    curl https://bootstrap.pypa.io/get-pip.py | sudo /Users/{your user name}/{path to python}/bin/python
    
    0 讨论(0)
  • 2020-11-21 13:53

    @Anupam's 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
    
    0 讨论(0)
  • 2020-11-21 13:54

    For all the python3 and pip3 users out there:

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

    and then assume you want to install pandas

    pip3 install pandas --user
    
    0 讨论(0)
  • 2020-11-21 13:55

    Following @Anupam's answer on OS X resulted in the following error for me, regardless of permissions I ran it with:

    Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: ...

    What eventually worked was to download a newer pip package (9.0.3) from PyPI directly from my browser - https://pypi.org/simple/pip/, extract the contents, and then pip install the package locally:

    pip install ./pip-9.0.3/
    

    This fixed my [SSL: TLSV1_ALERT_PROTOCOL_VERSION] errors.

    0 讨论(0)
提交回复
热议问题