lizarisk
lizarisk

Reputation: 7820

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

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.

Upvotes: 19

Views: 41761

Answers (6)

Rituraj Rautela
Rituraj Rautela

Reputation: 1

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.

Upvotes: 0

ye Gucheng
ye Gucheng

Reputation: 21

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.

Upvotes: 2

Viv
Viv

Reputation: 71

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

Upvotes: 2

edwardrbaker
edwardrbaker

Reputation: 763

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

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

Upvotes: 2

Aaron Lelevier
Aaron Lelevier

Reputation: 20810

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

Upvotes: 4

djc
djc

Reputation: 11731

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.

Upvotes: 31

Related Questions