【问题标题】:Google calendar API error under Python3Python3下的谷歌日历API错误
【发布时间】:2016-04-06 17:26:19
【问题描述】:

我正在使用具有以下设置的 google-api-python-client 库:

  • 虚拟环境中的 Python3.4.3(使用 pip8.1.1)

我收到以下代码的错误:AttributeError: 'module' object has no attribute 'file'

store = oauth2client.file.Storage(credential_path)

代码来自Google Python Quickstart 示例,在 Python 2.7.10 下运行良好

提前致谢!

【问题讨论】:

  • 如果你在 python 控制台中会发生什么,并执行以下操作:import oauth2client; dir(oauth2client) ?
  • 我得到以下信息:['GOOGLE_AUTH_URI', 'GOOGLE_DEVICE_URI', 'GOOGLE_REVOKE_URI', 'GOOGLE_TOKEN_INFO_URI', 'GOOGLE_TOKEN_URI', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__version__']
  • 你的oauth2client.__version__ 是什么?看看如果在 quickstart.py 代码中的 import oauth2client 之后添加 import oauth2client.file 会发生什么。或者,非常骇人听闻,from oauth2client import file as oauth2client_file; oauth2client.file = oauth2client_file.
  • 我的oath2client.__version__ 是'1.4.12'
  • 感谢您拍摄!至少我有一个真正的 问题,而且我没有错过一些愚蠢的东西。我想我会在另一台计算机上尝试重新设置,看看问题是否可重复。

标签: python python-3.4 google-api-client google-api-python-client


【解决方案1】:

我可以通过重写 import 语句让它工作: from oauth2client.file import Storage 不知道为什么会这样,但确实如此。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-11
    • 1970-01-01
    • 2019-09-08
    • 2016-12-14
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    • 2016-04-15
    相关资源
    最近更新 更多