My computer is running windows behind a proxy on a windows server (using active directory), and I can't figure out how to get through it with pip
(in python3). I have tried using --proxy
, but it still just timeouts. I have also tried setting a long timeout (60s), but that made no difference. My proxy settings are correct, and I compared them with those that I'm using successfully in TortoiseHG to make sure.
Are there any other tricks that anyone knows of that I can try, or is there some limitation in pip
with regards to windows proxies?
Update: My failed attempts involved searching pypi. I've just tried actually installing something and it worked. Searching still fails though. Does this indicate a bug in pip
or do they work differently?
I had a similar issue, and found that my company uses NTLM proxy authentication. If you see this error in your pip.log, this is probably the issue:
NTLMaps can be used to interface with the NTLM proxy server by becoming an intermediate proxy.
Download NTLMAPs, update the included server.cfg, run the main.py file, then point pip's proxy setting to 127.0.0.1:.
I also needed to change these default values in the
server.cfg
file to:http://ntlmaps.sourceforge.net/
You may also run into problems with certificates from your proxy. There are plenty of answers here on how to retrieve your proxy's certificate.
On a Windows host, to allow pip to clear your proxy, you may want to set an environment variable such as:
You can also use the
--cert
argument toPIP
with the same result.This is how I set it up:
Export the proxy settings :
set http_proxy=http://username:password@proxyAddress:port
set https_proxy=https://username:password@proxyAddress:port
Install the package you want to install:
pip install PackageName
For example:
I have tried 2 options which both work on my company's NTLM authenticated proxy. Option 1 is to use
--proxy http://user:pass@proxyAddress:proxyPort
If you are still having trouble I would suggest installing a proxy authentication service (I use CNTLM) and pointing pip at it ie something like
--proxy http://localhost:3128
install cntlm: Cntlm: Fast NTLM Authentication Proxy in C
Config cntlm.ini:
start it:
Now in cmd.exe:
works!
You can also hide password: https://stormpoopersmith.com/2012/03/20/using-applications-behind-a-corporate-proxy/
I ran into the same issue on windows 7. I managed to get it working by creating a "pip" folder with a "pip.ini" file inside it. I put this folder inside "C:\Users\{my.username}\AppData\Roaming", because according to the Python documentation:
In the pip.ini file I have only:
So no username:password. And it is working just fine.