每当我尝试通过 python 在 GAE 上运行示例代码时,我都会收到此错误
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1665, in LoadModuleRestricted
description)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/cgi.py", line 31, in <module>
import urllib
ImportError: No module named urllib
INFO 2012-04-15 04:44:54,345 dev_appserver.py:2884] "GET / HTTP/1.1" 500 -
我不确定问题是什么,我尝试了各种修复,就像这里提出的类似问题一样。
示例代码:
import webapp2
import urllib
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Hello, webapp World!')
app = webapp2.WSGIApplication([('/', MainPage)],
debug=True)
我在 Mac OSX 10.6.8 (Snow Leopard) 上运行并使用 Python 2.7.3