Mic*_*agg 1 python eclipse google-app-engine calendar
我对Python和Google App Engine都很陌生,我正在慢慢地尝试解决以下编译错误.
文件"/opt/google/google_appengine/google/appengine/tools/appengine_rpc.py" 26行,在进口cookielib文件"/usr/lib/python2.7/cookielib.py" 38行,从日历进口timegm ImportError:无法导入名称timegm
我正在使用Eclipse中的PyDev插件进行本地部署.据我所知,没有理由错误.我已经尝试将timegm.py文件夹添加到PYTHONPATH配置中,我甚至通过from calendar import timegm
在我的代码中使用auto complete 导入证明了这一点!
我见过其他人有问题,但没有解决方案.有人知道怎么修这个东西吗?
代码如下:
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)
Run Code Online (Sandbox Code Playgroud)
Dan*_*man 15
没有必要安装任何东西,calendar.timegm
是标准库中的一个功能.
可能发生的是你有一个名为的本地文件calendar.py
,它隐藏了stdlib版本.您的日历文件没有这样的功能,因此出错.将您的文件重命名为其他内容.
归档时间: |
|
查看次数: |
1174 次 |
最近记录: |