我已经这样做了一百万次,但由于某种原因,我在尝试使用 urllib2 时遇到了一些奇怪的错误。我最近从 Ubuntu 11.10 升级到 12.04。
代码:
from urllib2 import urlopen
urlopen('http://www.google.com').read()
结果:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
urlopen('http://www.google.com').read()
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 400, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 418, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1207, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1146, in do_open
h = http_class(host, timeout=req.timeout) # will parse host:port
File "/home/nate/httplib.py", line 362, in __init__
ImportError: No module named appengine.api
使用 urllib 时出现类似的错误。关于可能导致此问题以及如何解决此问题的任何想法?