'AttributeError: 'module' object has no attribute 'file'' when using oauth2client with Google Calendar

'AttributeError: 'module' object has no attribute 'file'' when using oauth2client with Google Calendar

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

AttributeError: 'module' object has no attribute 'file'

来自行

store = oauth2client.file.Storage(credential_path)

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

干杯, 杰克

在原始样本中

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

缺少导入条目:

   from oauth2client import file 

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