26

I am trying to use pip from behind a corporate firewall, and not having any luck.

I have set the http_proxy and https_proxy environment variables. wget works, but not pip.

I tried this ...

sudo -E pip install virtualenv

with these proxies ...

export http_proxy=myproxyname.mydomain.com:8080
export https_proxy=myproxyname.mydomain.com:8080 

... and got a long stacktrace which ended with this

/requests/packages/urllib3/poolmanager.py", line 214, in __init__
'Not supported proxy scheme %s' % self.proxy.scheme
AssertionError: Not supported proxy scheme None

I looked at the poolmanager.py source. It looks like it is requiring the proxy variables to begin with a scheme. So I tried again with the following proxies ...

export http_proxy=http://myproxyname.mydomain.com:8080
export https_proxy=https://myproxyname.mydomain.com:8080 (also tried this with http://)

... and I get the following error

Downloading/unpacking virtualenv
  Cannot fetch index base URL https://pypi.python.org/simple/
  Could not find any downloads that satisfy the requirement virtualenv
Cleaning up...
No distributions at all found for virtualenv
Storing debug log for failure in /root/.pip/pip.log

This is the same error I get when I do not have a proxy at all, though I get it much faster when the proxies are set.

When I try wget ...

wget --no-check-certificate https://pypi.python.org/simple/

It works fine, so I think the proxies themselves seem ok, unless I try them with pip.

Using the --proxy option instead of envvars did not help. Same results.

Any ideas?

Thanks, Bean

Bean Taxi
  • 1,104
  • 1
  • 9
  • 22

7 Answers7

23

Use the --trusted-host argument.

I figured out how to get it to work with me behind my corporate firewall using the --trusted-host argument.

My first attempt was this:

pip install matplotlib

and the failed text was this:

Could not fetch URL https://pypi.python.org/simple/matplotlib/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645) - skipping

So then I tried this which worked:

pip3.5 install matplotlib --trusted-host pypi.python.org

user3398996
  • 231
  • 2
  • 2
9

I had to set all this in Windows to make it work.

set http_proxy=http://proxy.corp.com:8083
set https_proxy=http://proxy.corp.com:8083
set all_proxy=http://proxy.corp.com:8083
set no_proxy=localhost,.corp.com

set HTTP_PROXY=http://proxy.corp.com:8083
set HTTPS_PROXY=http://proxy.corp.com:8083
set ALL_PROXY=http://proxy.corp.com:8083
set NO_PROXY=localhost,.corp.com

set PATH=c:\python27\scripts;c:\python27\;%PATH%

Please replace proxy.corp.com:8083 with your http proxy server.

After that I use pip install numpy

[Last ".corp.com" was missing a period (fixed it).... by the way, after MUCH hair-pulling from behind our corporate firewall, THIS solution was the only one that worked!]

Community
  • 1
  • 1
Damian
  • 4,395
  • 4
  • 39
  • 67
  • Thank you for answering Damian. Unfortunately I'm not at that job any more, so I can't even test if the above works on their firewall! However I've upvoted your answer, as it's the most thorough and mentions variables that I did not know about, and might help others. – Bean Taxi Feb 05 '16 at 15:01
  • 1
    Thank you, that worked for me as well... but something I didn't find anyware regarding when the password has special characters try setting as: `http://user:"password#with@special$chars"@IPADDRESS:PORT` – mrbTT May 30 '18 at 14:39
7

This worked for me (on linux centOS)

export HTTP_PROXY=http://myusr:mypswd@myproxyname.mydomain.com:8080
export HTTPS_PROXY=https://myusr:mypswd@myproxyname.mydomain.com:8080
sudo -E pip3 install --proxy http://myusr:mypswd@myproxyname.mydomain.com:8080 virtualenv
Joram
  • 3,166
  • 1
  • 22
  • 29
5

pip has an option to set the proxy, so the following should work for you:

sudo -E pip install --proxy="myproxyname.mydomain.com:8080" virtualenv
Odi
  • 6,916
  • 3
  • 34
  • 52
  • 2
    Thanks ... unfortunately this did not work either. It gives the same results as setting the environment variables, including the 'no scheme' issue if I don't begin the proxy with http. I'm going to edit the question to indicate I tried this. – Bean Taxi Jan 30 '14 at 22:33
5

Try adding "http://" before the proxy hostname:

sudo -E pip install --proxy="http://myproxyname.mydomain.com:8080" virtualenv
Roberto
  • 888
  • 8
  • 11
0

this is working behind a proxy

sudo -E pip --proxy username:password@http://IP:port install

Sasanka
  • 9
  • 1
0

On windows go to "Internet Properties" ---> "Connection" ---> "LAN Settings" and check the address (if it is a wpad.dat file, download it and look for "ProxyPort" and "ProxyServer").

Then try:

pip --proxy http://*user*:*password*@P*roxyServer*:*ProxyPort* install *module*
Caconde
  • 4,177
  • 7
  • 35
  • 32