我對Python和Google App Engine都很陌生,我正在努力解決以下編譯錯誤。GAE/Python ImportError timegm
File "/opt/google/google_appengine/google/appengine/tools/appengine_rpc.py", line 26, in import cookielib File "/usr/lib/python2.7/cookielib.py", line 38, in from calendar import timegm ImportError: cannot import name timegm
我使用Eclipse中的PyDev插件到本地部署。據我所知,沒有錯誤的原因。我已經嘗試將timegm.py文件夾添加到PYTHONPATH配置中,並且我甚至通過在我的代碼中使用auto complete完全導入from calendar import timegm
來證明這一點!
我見過別人的問題,但沒有解決方案。有人知道怎麼修這個東西嗎?
代碼如下:
import httplib2
import webapp2
from apiclient.discovery import build
from google.appengine.api import oauth
from oauth2client.client import OAuth2WebServerFlow
from urlparse import urlparse, parse_qs
class MainPage(webapp2.RequestHandler):
def get(self):
flow = OAuth2WebServerFlow(__CLIENT_ID, __CLIENT_SECRET, _SCOPE, _REDIRECT_URI)
authUri = flow.step1_get_authorize_url()
queryString = parse_qs(urlparse(authUri).query)
if 'error' not in queryString:
# Create an httplib2.Http object to handle our HTTP requests and authorize it
credentials = flow.step2_exchange(queryString['code'])
http = httplib2.Http()
http = credentials.authorize(http)
service = build("calendar", "v3", http=http)
events = service.events().list(calendarId=__VISITORS_CALENDAR).execute(http=http)
if events['items']:
# show what we've got
for event in events['items']:
self.response.write(event['summary'])
else:
self.response.write('No events found in the calendar')
else:
self.response.write('Denied...')
app = webapp2.WSGIApplication([('/', MainPage)], debug = True)
PS:縮進在我的文章中搞砸了,但在文件 – 2013-04-24 09:20:50
中很好,只是向python路徑添加東西不夠充分,您必須將任何第三方庫複製到您的項目中並直接操作sys.path。這是一個一遍又一遍的問及答案。如何首先搜索。 – 2013-04-24 09:25:08
我沒有打擾包含鏈接到同樣的問題有這麼多的重複;-) – 2013-04-24 09:40:37