Pip 不在防火墙后面工作 [英] Pip not working behind firewall
问题描述
我试图从公司防火墙后面使用 pip,但没有任何运气.
I am trying to use pip from behind a corporate firewall, and not having any luck.
我已经设置了 http_proxy
和 https_proxy
环境变量.wget 有效,但 pip 无效.
I have set the http_proxy
and https_proxy
environment variables. wget works, but not pip.
我试过了……
sudo -E pip install virtualenv
使用这些代理...
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
我查看了 poolmanager.py 源代码.看起来它要求代理变量以一个方案开始.所以我再次尝试使用以下代理...
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://)
...我收到以下错误
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.
当我尝试 wget 时......
When I try wget ...
wget --no-check-certificate https://pypi.python.org/simple/
它工作正常,所以我认为代理本身看起来还可以,除非我用 pip 尝试它们.
It works fine, so I think the proxies themselves seem ok, unless I try them with pip.
使用 --proxy
选项代替 envvars 没有帮助.相同的结果.
Using the --proxy
option instead of envvars did not help. Same results.
有什么想法吗?
谢谢,豆
推荐答案
使用 --trusted-host 参数.
Use the --trusted-host argument.
我想出了如何使用 --trusted-host 参数让它在我的公司防火墙后面与我一起工作.
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
失败的文本是这样的:
无法获取 URL https://pypi.python.org/simple/matplotlib/:有确认 ssl 证书时出现问题:[SSL:CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:645) -跳过
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 安装 matplotlib --trusted-host pypi.python.org
这篇关于Pip 不在防火墙后面工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!