Like it!

Join me on Facebook!

Like it!

Install Python modules with Pip behind a proxy

What to do when a proxy server steps on your toes?

I'm working on Debian Stretch with pip 1.5.6. I need to install a new Python module (Requests, the famous http library) but, being behind a nasty proxy, I can't get pip to work properly. This is the error I'm getting so far:

Cannot fetch index base URL
Could not find any downloads that satisfy the requirement requests
Cleaning up...
No distributions at all found for requests
Storing debug log for failure in /root/.pip/pip.log

Exporting https_proxy environment variables as I did in one of my previous articles didn't help. Eventually I found a nice and simple solution: the --proxy parameter for pip. Use it as follows:

sudo pip --proxy <proxy> install <module>

For example, if the proxy is http://proxy.hell:3128 and the module you want to install is requests:

sudo pip --proxy http://proxy.hell:3128 install requests

The same solution applies to pip3 as well.

Rohit Anand on January 04, 2019 at 17:24
But this method installs the package in my base python instead of installing it in the virtual environment. How can I fix it??
Triangles on January 05, 2019 at 12:19
@Rohit no clues. What about this?