PIP不起作用-代理
问题描述:
python pip在代理后面不起作用
python pip is not working behind proxy
我尝试了
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
,但是没有用.
and nothing is working, I also tried setting environment variables HTTP_PROXY
but it isn't working.
例如,这是尝试安装toolz时的错误:
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
答
问题出在加载旧代理设置的conf文件中.同样,环境变量区分大小写.因此,通过在Linux中使用printenv
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
然后按照@MedAli的建议:在使用pip
的同时添加--proxy
会起作用
Then as @MedAli suggested: adding --proxy
while using pip
will work