Python – Using pip behind a proxy with CNTLM

pipPROXYpython

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?

Best Answer

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

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:

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

then

sudo -E pip install somepackage