Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

pip

proxy

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 the command without sudo, the package downloads successfully, but I don't have enough permissions. What could be the reason for such different behaviour? I'm sitting behind a proxy.

like image 950
lizarisk Avatar asked Mar 19 '13 13:03

lizarisk


3 Answers

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.

like image 74
djc Avatar answered Sep 25 '22 02:09

djc


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

like image 4
Aaron Lelevier Avatar answered Sep 23 '22 02:09

Aaron Lelevier


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

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

like image 2
edwardrbaker Avatar answered Sep 22 '22 02:09

edwardrbaker