Google Drive API - ImportError:无法导入名称util

时间:2016-11-20 19:40:46

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

我正在尝试按照本教程:https://developers.google.com/drive/v3/web/quickstart/python#step_1_turn_on_the_api_name

然而,当我运行它时,我收到以下错误:

Traceback (most recent call last):
  File "test.py", line 5, in <module>
    from apiclient import discovery
  File "/Library/Python/2.7/site-packages/apiclient/__init__.py", line 16, in <module>
    from googleapiclient import channel
  File "/Library/Python/2.7/site-packages/googleapiclient/channel.py", line 62, in <module>
    from googleapiclient import errors
  File "/Library/Python/2.7/site-packages/googleapiclient/errors.py", line 25, in <module>
    from oauth2client import util
ImportError: cannot import name util

我已尝试使用我所阅读的Google API 1.3.2版可能会解决问题,但似乎没有改变任何内容。

我对Python很新。

1 个答案:

答案 0 :(得分:5)

我的第一个猜测是你的oauth2client版本与你的google-api-python-client版本不兼容。

尝试将google-api-python-client == 1.5.2与oauth2client == 2.2.0结合使用,例如