PIP not working - proxy

2019-03-01 00:23发布

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

标签: proxy pip
2条回答
倾城 Initia
2楼-- · 2019-03-01 00:44

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

查看更多
成全新的幸福
3楼-- · 2019-03-01 00:47

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> 
查看更多
登录 后发表回答