PIP不工作 - 代理

时间:2017-07-07 16:04:25

标签: proxy pip

python pip无法在代理

后面工作

我试过

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

并且没有任何工作,我也尝试设置环境变量HTTP_PROXY,但它不起作用。

例如,尝试安装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

2 个答案:

答案 0 :(得分:2)

我经常在代理后面使用pip install。这是适用于我的语法:

sudo pip --proxy username:password@ip_address:port install <package_name> 

答案 1 :(得分:2)

问题出在加载旧代理设置的conf文件中。环境变量也区分大小写。因此,在linux中使用printenv检查HTTP_PROXY和http_proxy之间是否存在差异

然后正如@MedAli建议的那样:在使用--proxy时添加pip将会有效