Reputation: 3276
I used to set up environment evariables http_proxy and https_proxy (with user + password) in the past to use Pip (on Windows) behind a corporate proxy. But recently I needed to tell Pip to use a proxy without setting up environment variables as this conflicted with git configuration in combination with SSL Certificates which I get to work only by removing environment variables for proxy.
Fortunately you can configure PIP with an pip.ini file as described here: https://pip.pypa.io/en/stable/user_guide/#config-file
The detailed answer to my own question follows below.
Upvotes: 38
Views: 142497
Reputation: 910
I know the question mentioned it's about Windows, but for those who are in Linux:
~/.config/pip/pip.conf
(if it's not there create it).[global]
proxy = http://127.0.0.1:12345
%APPDATA%\pip\pip.ini
(if it's not there create it).proxy = http://127.0.0.1:12345
You can always use the --proxy
option of pip
itself to use a custom proxy:
pip install PACKAGE --proxy http://127.0.0.1:12345
You need to change the http://127.0.0.1:12345 with your proxy. It also can contain a username and password:
Protocol://Username:Password@ProxyHost:ProxyPort
Upvotes: 0
Reputation: 1864
A little easier with:
pip config set global.proxy http://{host}:{port}
and it will persist the setting automagically
Writing to C:\Users\{username}\AppData\Roaming\pip\pip.ini
Upvotes: 40
Reputation: 336
If package that you are trying to install has dependencies it's best to create pip.ini for system wide configuration, in windows you can do this in powershell:
mkdir c:\programdata\pip\
new-item c:\programdata\pip\pip.ini
and add this to your pip.ini
[global]
proxy = http://domain\user:pwd@proxy_hostname_or_ip:port
and then everything should work fine, as HTTP_PROXY variable didn't work for me.
Make sure to save file as ansi or windows1252 in VSCode as UTF files are not read properly.
Upvotes: 3
Reputation: 129
You need to set proxy option while installing the package. example:
pip install --proxy userid:[email protected]:yourport
Upvotes: 6
Reputation: 161
In order to add a proxy option in the terminal the following line solved the problem for me:
pip install package_name_here --proxy https://user_name:password@proxyname:port
Upvotes: 16
Reputation: 3276
Here are the steps how to configure proxy (with auth.) in pip's config file (pip.ini)
edit pip.ini file and add
[global]
proxy = http://user:password@proxy_name:port
Example for proxy with authentification (user + password):
proxy = http://butch:secret@proxyname:1234
proxyname can be an IP adress, too
Example for proxy without auth.:
proxy = http://proxyname:1234
Upvotes: 60