lizarisk lizarisk - 2 years ago 177
Python Question

Python pip error: "Cannot fetch index base URL"

I'm trying to install several packages using pip. When I do this using sudo, this error occurs: "Cannot fetch index base URL". 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.

djc djc
Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download