Using pip behind a proxy

2018-12-31 15:16发布

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

One of the answers from this post suggested using 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.

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/. 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? 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?

标签: python proxy pip
26条回答
素衣白纱
2楼-- · 2018-12-31 16:01

Set up invironment variable in Advanced System Settings. In Command prompt it should behave like this :

C:\Windows\system32>echo %http_proxy%

http://username:passowrd@proxy:port

C:\Windows\system32>echo %https_proxy%

http://username:password@proxy:port

Later , Simply pip install whatEver should work.

查看更多
大哥的爱人
3楼-- · 2018-12-31 16:02

At CentOS (actually I think all linux distros are similar) run

env|grep http_proxy

and

env|grep https_proxy

check what is the output of those commands (they should contain your proxy addresses).

If the outputs are empty or have incorrect values, modify them, for ex:

export http_proxy=http://10.1.1.1:8080
export https_proxy=http://10.1.1.1:8080

Now try to fetch and install some packages by using pip:

pip --proxy http://10.1.1.1:8080 install robotframework

and actually I have never met the case when it didn't work. For some systems you need to be a root (sudo is not enough).

查看更多
姐姐魅力值爆表
4楼-- · 2018-12-31 16:04

Under Windows dont forget to set

SET HTTPS_PROXY=<proxyHost>:<proxyPort>

what I needed to set for

pip install pep8
查看更多
冷夜・残月
5楼-- · 2018-12-31 16:05

I was not working to me. I used https for works:

pip install --proxy=https://user@mydomain:port somepackage

In order to update, add -U.

查看更多
不流泪的眼
6楼-- · 2018-12-31 16:05

In Ubuntu 14.04 LTS

   sudo pip --proxy http://PROXYDOM:PROXYPORT install package

Cheers

查看更多
只靠听说
7楼-- · 2018-12-31 16:07
$ pip --proxy http://proxy-host:proxy-port install packagename

This is what worked for me on

查看更多
登录 后发表回答