1

python pip is not working behind proxy

I tried

sudo -H pip --proxy https://proxy_ip:proxy_port install <package>

sudo -H pip --proxy https://usename:password@proxy_ip:proxy_port install <package>

sudo easy_install pip

and nothing is working, I also tried setting environment variables HTTP_PROXY but it isn't working.

For instance, here is the error when trying to install toolz:

 Collecting toolz
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/toolz/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/toolz/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/toolz/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/toolz/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/toolz/
  Could not find a version that satisfies the requirement toolz (from versions: )
No matching distribution found for toolz
Mohamed Ali JAMAOUI
  • 14,275
  • 14
  • 73
  • 117
severine
  • 305
  • 1
  • 3
  • 11

2 Answers2

2

I use pip install behind a proxy frequently. Here's the syntax that's working for me:

sudo pip --proxy username:password@ip_address:port install <package_name> 
Mohamed Ali JAMAOUI
  • 14,275
  • 14
  • 73
  • 117
2

The problem was within a conf file that loads old proxy settings. Also the environment variables are case sensitive. So check if there is a difference between HTTP_PROXY and http_proxy by using printenv in linux

Then as @MedAli suggested: adding --proxy while using pip will work

severine
  • 305
  • 1
  • 3
  • 11