每當我試着通過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