Sublime Forum

Configuring ST2 Proxy settings

#1

I’ve a simple script which uses urllib2.urlopen(). If I run it via the terminal with ‘python script.py’, it runs flawlessly.
But if I run it in sublime text 2 via ‘CTRL+B’, it gives me this error

"Traceback (most recent call last): File "/path/to/script/script.py", line 10, in <module> response = urllib2.urlopen("http://google.com") File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen return _opener.open(url, data, timeout) File "/usr/lib/python2.7/urllib2.py", line 406, in open response = meth(req, response) File "/usr/lib/python2.7/urllib2.py", line 519, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/python2.7/urllib2.py", line 444, in error return self._call_chain(*args) File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain result = func(*args) File "/usr/lib/python2.7/urllib2.py", line 527, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 407: Proxy Authentication Required [Finished in 0.4s with exit code 1]"

My proxy is set in the http_proxy and https_proxy environment variables and in /etc/environment.

What do I need to configure for using urllib2 in ST2. And no I don’t want to use Requests :stuck_out_tongue:

0 Likes

#2

Sublime doesn’t pick all environment variables (especially those defined in .bashrc/.profile/…). So a solution would be to define the proxy manually in your script:

import os os.environ'http_proxy'] = 'http://.../'

Proxy support is broken in requests, anyway :smile:

0 Likes