Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
357 views
in Technique[技术] by (71.8m points)

python - 在CNTLM的代理后面使用pip(Using pip behind a proxy with CNTLM)

I am trying to use pip behind a proxy at work.

(我正在尝试在工作中使用代理后面的点子。)

One of the answers from this post suggested using CNTLM .

(这篇文章的答案之一是建议使用CNTLM 。)

I installed and configured it per this other post , but running cntlm.exe -c cntlm.ini -I -M http://google.com gave the error Connection to proxy failed, bailing out .

(我已根据 cntlm.exe -c cntlm.ini -I -M http://google.com 文章进行了安装和配置,但是运行cntlm.exe -c cntlm.ini -I -M http://google.com出现错误,导致Connection to proxy failed, bailing out 。)

I also tried pip install -–proxy=user:pass@localhost:3128 (the default CNTLM port) but that raised Cannot fetch index base URL http://pypi.python.org/simple/ .

(我还尝试了pip install -–proxy=user:pass@localhost:3128 (默认的CNTLM端口),但提出了Cannot fetch index base URL http://pypi.python.org/simple/ 。)

Clearly something's up with the proxy.

(显然,代理出现了问题。)

Does anyone know how to check more definitively whether CNTLM is set up right, or if there's another way around this altogether?

(有谁知道如何更明确地检查CNTLM是否设置正确,或者是否还有其他方法可以完全解决这一问题?)

I know you can also set the http_proxy environment variable as described here but I'm not sure what credentials to put in. The ones from cntlm.ini ?

(我知道您也可以按此处所述设置http_proxy环境变量,但是我不确定要放入什么凭据cntlm.ini ?)

  ask by Rob translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

With Ubuntu I could not get the proxy option to work as advertised – so following command did not work:

(与Ubuntu我不能让代理选项,以工作为标榜-所以下面的命令没有工作:)

sudo pip --proxy http://web-proxy.mydomain.com install somepackage

But exporting the https_proxy environment variable (note its https_proxy not http_proxy ) did the trick:

(但是导出https_proxy环境变量(注意,它的https_proxy不是http_proxy )可以达到目的:)

export https_proxy=http://web-proxy.mydomain.com

then

(然后)

sudo -E pip install somepackage

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...