Im trying to install some pip packages behind a proxy. Ive set the env to,
http_proxy=http://172.16.2.3:3128
https_proxy=http://172.16.2.3:3128
I then tried pip but get the error,
[root@server ~]# pip install --proxy=http://172.16.2.3:3128 virtualenv -v
Starting new HTTPS connection (1): pypi.python.org
There was an error checking the latest version of pip
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pip/utils/outdated.py", line 122, in pip_version_check
headers={"Accept": "application/json"},
File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 477, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python2.7/site-packages/pip/download.py", line 373, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol/adapter.py", line 46, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/adapters.py", line 424, in send
raise ConnectionError(e, request=request)
ConnectionError: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /pypi/pip/json (Caused by ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 403 Forbidden',)))
Collecting virtualenv
Getting page https://pypi.python.org/simple/virtualenv/
Starting new HTTPS connection (1): pypi.python.org
Incremented Retry for (url='/simple/virtualenv/'): Retry(total=4, connect=None, read=None, redirect=None)
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 403 Forbidden',))': /simple/virtualenv/
However curl appears to work (?)
[root@server ~]# curl -I https://pypi.python.org/simple/virtualenv/
HTTP/1.1 200 Connected
HTTP/1.1 200 OK
Server: nginx/1.8.0
Content-Type: text/html; charset=utf-8
X-PYPI-LAST-SERIAL: 1916396
Cache-Control: max-age=600, public
X-Clacks-Overhead: GNU Terry Pratchett
Any ideas ?
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.
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 “pip: command not found” error occurs when you fail to properly install the package installer for Python (pip) needed to run Python on your computer. To fix it, you will either need to re-install Python and check the box to add Python to your PATH or install pip on your command line.
You can specify the proxy as a parameter to pip install:
pip install <package> --proxy http://your.proxy.net:8080/
If you also face ssl certificate errors (also common in corporate environments), you can enable pypi as a trusted host as well:
pip install <package> --proxy http://your.proxy.net:8080/ --trusted-host pypi.python.org
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