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?
pip can be configured to connect through a proxy server in various ways: using the --proxy command-line option to specify a proxy in the form scheme://[user:passwd@]proxy.server:port. using proxy in a Configuration Files. by setting the standard environment-variables http_proxy , https_proxy and no_proxy .
A proxy server for pip is most commonly used for security and privacy, but can also be used for control: Security & Privacy – a proxy server can be used in combination with firewalls in order to improve internal network security since requests from users on the local network are anonymized via a proxy server.
In Windows 10 menu, go to Settings (WinKey+I) and search for "Credential Manager". Under Windows Credentials, add a new entry for Windows Credentials. Enter the Proxy Server address (without the port number), your domain user name and the password.
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
It took me a couple hours to figure this out but I finally got it to work using CNTLM and afterwards got it to work with just a pip config file. Here is how I got it work with the pip config file...
Solution:
1. In Windows navigate to your user profile directory (Ex. C:\Users\Sync) and create a folder named "pip"
2. Create a file named "pip.ini" in this directory (Ex. C:\Users\Sync\pip\pip.ini) and enter the following into it:
[global] trusted-host = pypi.python.org pypi.org files.pythonhosted.org proxy = http://[domain name]%5C[username]:[password]@[proxy address]:[proxy port]
Replace [domain name], [username], [password], [proxy address] and [proxy port] with your own information.
Note, if your [domain name], [username] or [password] has special characters, you have to percent-encode | encode them.
3. At this point I was able to run "pip install" without any issues.
Hopefully this works for others too!
P.S.: This may pose a security concern because of having your password stored in plain text. If this is an issue, consider setting up CNTLM using this article (allows using hashed password instead of plain text). Afterwards set proxy = 127.0.0.1:3128
in the "pip.ini" file mentioned above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With