Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proxy awareness with pip

Tags:

python

pip

proxy

I have tried to set up a python development environment at my work place to create some basic applications. I can't seem to get pip to work, for example I type in pip install numpy and get the following error message:

  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip ._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x035884B0>, 'Connection to pypi.python. org timed out. (connect timeout=15)')': /simple/numpy/ 

The research I have done seems to indicate that proxy awareness is my issue, is this correct, if so I am not really sure on what this means exactly or how to resolve it.

like image 253
Tom Avatar asked Jun 23 '15 02:06

Tom


People also ask

How do I pass a proxy to pip?

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 .

How do you pass a proxy in Python?

To use a proxy in Python, first import the requests package. Next create a proxies dictionary that defines the HTTP and HTTPS connections. This variable should be a dictionary that maps a protocol to the proxy URL. Additionally, make a url variable set to the webpage you're scraping from.


2 Answers

If you know your proxy information, you can pass that to your command line:

pip install --proxy=user:pass@server:port numpy 

A full string could be something as simple as:

pip install --proxy=http://proxy.example.com numpy 

Where proxy.example.com is your (corporate) proxy server. You only need to pass user:pass and port if the proxy also requires that information.

like image 164
Andy Avatar answered Oct 01 '22 09:10

Andy


pip doesn't work if you are using a proxy server for installing packages. To fix it: Go to control panel -> Internet options -> Connections ->LAN Settings ->Unmark 'use proxy server' options. Try using pip after this, it should work. You can start using proxy server after installing the package.

like image 21
The_Vats Avatar answered Oct 01 '22 10:10

The_Vats