每当我试着通过Python运行在GAE上的样本代码,我得到这个错误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 -
我不知道是什么问题,我尝试了各种修补,“没有命名的urllib模块”在这里提出类似的问题。
示例代码:
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(雪豹)上运行,并使用Python 2.7.3
有趣的是,它是一个内置模块(cgi.py),它会抛出错误。和urllib在那里!不知道为什么会发生这种情况! – adifire 2012-04-15 13:09:07
在首选项中将Python路径设置为'/ usr/local/bin/python2.7' – 2012-09-06 21:07:07