9

I am not super technical person. But I know that in Windows if I install R using the internet2 option then I can download whatever package I want in it.

I install Python and everytime I try to download a package or install a package (e.g. using easy_install) it fails.

What can I do to make Python automatically detect my proxy settings and just install the packages?

eis
  • 51,991
  • 13
  • 150
  • 199
xiaodai
  • 14,889
  • 18
  • 76
  • 140

2 Answers2

10

Set up environment variable http_proxy / https_proxy to http://your-proxy-server-address:proxy-port

The urlopen() function works transparently with proxies which do not require authentication. In a Unix or Windows environment, set the http_proxy, or ftp_proxy environment variables to a URL that identifies the proxy server before starting the Python interpreter. For example (the '%' is the command prompt):

% http_proxy="http://www.someproxy.com:3128"
% export http_proxy
% python
...

The no_proxy environment variable can be used to specify hosts which shouldn’t be reached via proxy; if set, it should be a comma-separated list of hostname suffixes, optionally with :port appended, for example cern.ch,ncsa.uiuc.edu,some.host:8080.

falsetru
  • 357,413
  • 63
  • 732
  • 636
  • I did mention Windows XP in my post. Thanks though. – xiaodai Jun 22 '13 at 10:30
  • @xiaodai, This works in Windows as mentioned in my answer quote. I tested it under Windows XP 32bit. – falsetru Jun 22 '13 at 10:54
  • % http_proxy="http://www.someproxy.com:3128" % export http_proxy % python is Windows cmd prompt code? Powershell? I thought it was some unix command. Also i cannot set up environment varibles in windows as I don't have adminstrative priveledge as I work in a corporate environment. – xiaodai Jun 22 '13 at 11:59
  • 1
    @daveL, Specify the proxy in the following form: `http://username:password@someproxy.com:3128` – falsetru Jan 07 '14 at 11:49
  • 2
    this doesn't really answer the question though. I guess it's not possible to tell python to automatically use windows proxy settings, but for the time being, you have to set it yourself. Also, this answer doesn't help if you're using HTTPConnection or something, where you need to specify the proxy as a parameter. – eis Nov 11 '16 at 09:18
3

Or use the HTTP_PROXY / HTTPS_PROXY setting instead.

Andres
  • 39
  • 2