Python pip error: “Cannot fetch index base URL https://pypi.python.org/simple/”

后端 未结 6 632
死守一世寂寞
死守一世寂寞 2021-02-05 08:38

I\'m trying to install several packages using pip. When I do this using sudo, this error occurs: \"Cannot fetch index base URL https://pypi.python.org/simple/\". When I execute

相关标签:
6条回答
  • 2021-02-05 08:41

    From the pip docs, if you are installing behind a proxy:

    python get-pip.py --proxy="[user:passwd@]proxy.server:port"

    0 讨论(0)
  • 2021-02-05 08:45

    If you want to install any packages using pip then it is better to follow below syntax:

    sudo pip --proxy=http://username:password@proxyURL:portNumber install yolk
    
    0 讨论(0)
  • 2021-02-05 08:51

    I got this issue when trying to use pip==1.5.4

    This is an issue related to PIP and Python's PYPI trusting SSL certificates. If you look in the PIP log in Mac OS X at: /Users/username/.pip/pip.log it will give you more detail.

    My workaround to get PIP back up and running after hours of trying different stuff was to go into my site-packages in Python whether it is in a virtualenv or in your normal site-packages, and get rid of the current PIP version. For me I had pip==1.5.4

    I deleted the PIP directory and the PIP egg file. Then I ran

    easy_install pip==1.2.1  
    

    This version of PIP doesn't have the SSL issue, and then I was able to go and run my normal pip install -r requirements.txt within my virtualenv to set up all packages that I wanted that were listed in my requirements.txt file.

    This is also the recommended hack to get passed the issue by several people on this Google Group that I found:

    https://groups.google.com/forum/#!topic/beagleboard/aSlPCNYcVjw

    [edit]

    If you have a different version of PIP installed globally, every time you create a new virtualenv it will install that version of PIP, so you will have to do this each time for each new PIP unless you change the globally installed version. I ran into this issue when starting a new project, and had to do the fix again and revert back to pip==1.2.1

    0 讨论(0)
  • 2021-02-05 09:00

    My solution was different for this problem.

    My system's Date and Time were not synchronized.

    If the problem appears check your system data/time if that's not the problem proceed with the another suggestions.

    0 讨论(0)
  • 2021-02-05 09:04

    Maybe try with sudo -E:

     -E          The -E (preserve environment) option indicates to the secu‐
                 rity policy that the user wishes to preserve their existing
                 environment variables.  The security policy may return an
                 error if the -E option is specified and the user does not
                 have permission to preserve the environment.
    

    On the assumption that your proxy settings are set in your normal user environment, but not the one you get when you run sudo.

    0 讨论(0)
  • 2021-02-05 09:04

    I have encountered this problem and found the answer finally solved.

    You can try to add a new file/root/.pip/pip.conf, then write:

    [global]
    index-url=http://pypi.douban.com/simple/ 
    

    in the file.

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