'AttributeError:'模块'对象在将oauth2client与Google Calendar结合使用时没有属性'file''

JMz*_*nce 5 python calendar google-calendar-api oauth-2.0 oauth2client

我正在使用google calendars python api(https://developers.google.com/google-apps/calendar/quickstart/python#step_3_set_up_the_sample)的示例脚本来尝试打印出所有日历事件.但是我收到的错误是:

AttributeError: 'module' object has no attribute 'file'
Run Code Online (Sandbox Code Playgroud)

从线

store = oauth2client.file.Storage(credential_path)
Run Code Online (Sandbox Code Playgroud)

我在文档中找不到对此类错误的引用.有没有其他人遇到过这个?

干杯,杰克

小智 15

在原始样本中

https://developers.google.com/google-apps/calendar/quickstart/python#step_3_set_up_the_sample

缺少进口条目:

   from oauth2client import file 
Run Code Online (Sandbox Code Playgroud)

添加此行并尝试再次运行您的脚本