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
?
for windows; set your proxy in command prompt as
set HTTP_PROXY=domain\username:password@myproxy:myproxyport
example:
set http_proxy=IND\namit.kewat:xl123456@192.168.180.150:8880
I am also no expert in this but I made it work by setting the
all_proxy
variable in the ~/.bashrc file. To open~/.bashrc
file and edit it from a terminal run following commands,Add following at the end of file,
Then either open a new terminal or run following in the same terminal,
Just setting
http_proxy
andhttps_proxy
variables aren't enough for simple usagepip install somepackage
. Though somehowsudo -E pip install somepackage
works, but this have given me some problem in case I am using a local installation of Anaconda in my users' folder.P.S. - I am using Ubuntu 16.04.
This is what works for me:
I got the error:
(The proxy server's port is ssh port forwarded to
localhost:3128
).I had to set both http and https proxies to make it work:
as
http://pypi.python.org/simple/
redirects tohttps://pypi.python.org/simple
butpip
's error does not tell you.You can continue to use pip over HTTPS by adding your corporation's root certificate to the cacert.pem file in your site-packages/pip folder. Then configure pip to use your proxy by adding the following lines to ~/pip/pip.conf (or ~\pip\pip.ini if you're on Windows):
That's it. No need to use third party packages or give up HTTPS (of course, your network admin can still see what you're doing).
Warning, there is something very bad with the "pip search" command. The search command do not use the proxy setting regardless of the way it's being passed.
I was trying to figure out the problem only trying the "search" command, and found this post with detailed explanation about that bug: https://github.com/pypa/pip/issues/1104
I can confirm the bug remains with pip 1.5.6 on Debian 8 with python 2.7.9. The "pip install" command works like a charm.