platform issues?

Adrian Powell adrianp at bringtechnology.com
Thu Dec 1 12:41:22 EST 2011


I'm new to python and I'm trying to get a twitter client running on a new machine but it keeps on failing. I tracked the problem down to an issue opening URLs and wrote this little test case:

import urllib2
url = 'http://www.google.com/'
opener = urllib2.build_opener()
url_data = opener.open(url).read
url_data


When I run that on a dev machine it works fine, but when it's on one of our servers it crashes:

>>> import urllib2
>>> url = 'http://www.google.com/'
>>> opener = urllib2.build_opener()
>>> url_data = opener.open(url).read
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1173, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1148, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>


Our servers have the same version of python and we're running the same OS (Fedora 14). Can anyone think of what might be causing this problem, or why it works on most (but not all) machines?

Thanks



More information about the Python-list mailing list