Configuring PIP to work from behind a proxy

2019-05-10 04:05发布

问题:

I've installed python 3.4.3 which comes with pip. I want to use pip from behind a proxy so I did the following:

Created C:\Users\foo\pip\pip.ini and added a proxy configuration section:

[proxy]
export http_proxy=my_proxy_server:1234

However, when I try to run pip to install packages, I get timeout messages:

C:\Users\foo>pip install paramiko Requirement already satisfied (use --upgrade to upgrade): paramiko in c:\python3 4\lib\site-packages\paramiko-1.16.0-py3.4.egg Collecting pycrypto!=2.4,>=2.1 (from paramiko) Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connec tion broken by 'ConnectTimeoutError(, 'Connection to pypi.python. org timed out. (connect timeout=15)')': /simple/pycrypto/

Any ideas what I'm doing wrong?

Thanks in Adv.!

回答1:

You can use the following command so that pip uses your proxy. The basic format is of this form:

 [user:passwd@]proxy.server:port

For example:

pip --proxy http://<your proxy>:<your port> (for http)
pip --proxy https://<your proxy>:<your port> (for https)


回答2:

You can set the proxy in "/etc/pip.conf":

[global]
proxy = http://host:port


标签: python proxy pip