pip connection failure: cannot fetch index base URL http://pypi.python.org/simple/

后端 未结 30 917
后悔当初
后悔当初 2020-11-28 23:19

I run sudo pip install git-review, and get the following messages:

Downloading/unpacking git-review
  C         


        
相关标签:
30条回答
  • 2020-11-28 23:33

    I too used the chosen solution (downgrading pip) to work around this issue until I ran into another seemingly unrelated issue caused by the same underlying problem. Python's version of OpenSSL was out of date. Check your OpenSSL version:

    python -c 'import ssl; print(ssl.OPENSSL_VERSION)'
    

    If the version is 0.9.7, that should verify that OpenSSL needs to be updated. If you know how to do that directly, great (but please let me know in a comment). If not, you can follow the advice in this answer, and reinstall python from the 64 bit/32 bit installer instead of the 32 bit only installer from python.org (I'm using python 3.4.2). I now have OpenSSL version 0.9.8, and none of these issues.

    0 讨论(0)
  • 2020-11-28 23:35

    I added --proxy command line option to point to the proxy and it's working (pip version is 1.5.4 and python 2.7). for some reason it was not taking the shell env variables HTTPS_PROXY, HTTP_PROXY, https_proxy, http_proxy.

    sudo pip --proxy [user:passwd@]proxy.server:port install git-review
    
    0 讨论(0)
  • 2020-11-28 23:35

    Check your proxy connection, I had a similar issue, then I changed my connection which wasn't proxied and boom, of it started downloading and setting up the library

    0 讨论(0)
  • 2020-11-28 23:37

    in my case I would install django (

    pip install django

    ) and it has a same problem with ssl certificate (Cannot fetch index base URL http://pypi.python.org/simple/ )

    it's from virtualenv so DO :

    FIRST: delete your virtualenv

    deactivate rm -rf env

    SECOND: check have pip

    pip3 -V

    if you don't have

    sudo apt-get install python3-pip

    FINALLY:

    install virtualenv with nosite-packages and make your virenviroment

    sudo pip3 install virtualenv virtualenv --no-site-packages -p /usr/bin/python3.6

    . env/bin/activate

    0 讨论(0)
  • 2020-11-28 23:37

    In case you use a firewall, make sure outbound connections to port 443 are not blocked, e.g. run:

    sudo iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
    
    0 讨论(0)
  • 2020-11-28 23:37

    I'm now getting this in $HOME/.pip/pip.log:

    Could not fetch URL https://pypi.python.org/simple/: HTTP Error 403: TLSv1.2+ is required
    

    I don't have a straightforward solution for this, but I'm mentioning it as something to watch out for before you waste time on trying some of the other solutions here.

    • I'm obviously already using a https URL
    • There is no proxy or firewall issue
    • Using trusted-host didn't change anything (dunno where I picked this up)

    For what it's worth my openssl is too old to even have ssl.OPENSSL_VERSION so maybe that's really the explanation here.

    In the end, wiping my virtual environment and recreating it with virtualenv --setuptools env seems to have fixed at least the major blockers.

    This is on a really old Debian box, Python 2.6.6.

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