Unable to install Python libraries

后端 未结 7 843
名媛妹妹
名媛妹妹 2020-11-27 22:53

I am not able to install any Python libraries. I am using pip 9.0.1 and python 2.7. I am getting the following error:

EN-NishantS:~         


        
相关标签:
7条回答
  • 2020-11-27 23:14

    A coworker also on macOS v10.12 (Sierra) just solved this by running brew install python@2 and then overwriting the previous version. It seems like the the version off the Python website is not bundling the correct OpenSSL version.

    I think someone has also filed a bug for this to Python directly: OS X system OpenSSL deprecated - installer should build local libssl

    0 讨论(0)
  • 2020-11-27 23:18

    On Mac you can do sudo curl https://bootstrap.pypa.io/get-pip.py | python

    0 讨论(0)
  • 2020-11-27 23:19

    I was having the same issue today trying to install Django.

    I just re-installed pip. Get get-pip.py from https://pip.pypa.io/en/stable/installing/ and just run python get-pip.py in your virtualenv. That should overwrite the existing installation and update the SSL certificate.

    0 讨论(0)
  • 2020-11-27 23:23

    It seems this issue is generating quite a few questions on Stack Overflow about various packages not getting installed using pip install package-name. So I thought I'll copy over my answer from here for more clarity on the issue:

    The solution is to upgrade pip to the latest version.

    However, upgrading pip via pip install --upgrade pip may not upgrade it correctly (it will show it's up-to-date even when it's not).

    So (for Mac users, for example), we need to upgrade pip as follows:

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

    What's happening:

    Python.org sites are stopping support for TLS versions 1.0 and 1.1. This means that Mac OS X version 10.12 (Sierra) or older will not be able to use pip unless they upgrade pip as above.

    This thread explains it (thanks to this Twitter post):

    Mac users who use pip and PyPI:

    If you are running macOS/OS X version 10.12 or older, then you ought to upgrade to the latest pip (9.0.3) to connect to the Python Package Index securely:

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

    and we recommend you do that by April 8th.

    Pip 9.0.3 supports TLSv1.2 when running under system Python on macOS < 10.13. Official release notes: https://pip.pypa.io/en/stable/news/

    Also, the Python status page:

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

    Update - The rolling brownouts have been upgraded to a blackout, TLSv1.0 and TLSv1.1 will be rejected with a HTTP 403 at all times. Apr 8, 15:49 UTC

    Lastly, to avoid other install errors, make sure you also upgrade setuptools after doing the above:

    pip install --upgrade setuptools
    
    0 讨论(0)
  • 2020-11-27 23:27

    Your HTTP request to PyPI fails with an HTTP 403 (Forbidden) error:

    HTTPError: 403 Client Error: TLSv1.2+ is required for url:
    

    https://pypi.python.org/pypi/pip/json

    Apparently pip is trying to access PyPI via HTTPS (which is encrypted and fine), but with an old (insecure) SSL version. Your system seems to be out of date. It might help if you update your packages.

    On Debian-based systems I'd try:

    apt-get update && apt-get upgrade python-pip
    

    On Red Hat Linux-based systems:

    yum update python-pip # (or python2-pip, at least on Red Hat Linux 7)
    

    On Mac:

    sudo easy_install -U pip
    

    You can also try to update openssl separately.

    0 讨论(0)
  • 2020-11-27 23:27

    I successfully upgraded Python 3 on macOS v10.13 (High Sierra) using sudo pip3 install --upgrade pip.

    To upgrade the High Sierra version 2.7 I had to use sudo pip2 install --upgrade pip.

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