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?

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

5 Comments

I did mention Windows XP in my post. Thanks though.
@xiaodai, This works in Windows as mentioned in my answer quote. I tested it under Windows XP 32bit.
% http_proxy="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.
@daveL, Specify the proxy in the following form: http://username:[email protected]:3128
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.
3

Or use the HTTP_PROXY / HTTPS_PROXY setting instead.

1 Comment

In some LAN scenarios, it's really hard to figure out what those values should be.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.