python - Google Drive SDK 快速入门示例 "ImportError: cannot import name util"错误

标签 python google-drive-api google-api-python-client

我在尝试 Google Drive SDK 快速入门示例 (https://developers.google.com/drive/quickstart) 时收到以下错误消息。

Traceback (most recent call last):
  File "quickstart.py", line 6, in <module>
    from apiclient.discovery import build
  File "build/bdist.macosx-10.6-intel/egg/apiclient/discovery.py", line 45, in <module>
  File "build/bdist.macosx-10.6-intel/egg/apiclient/errors.py", line 26, in <module>
ImportError: cannot import name util

如教程中所述,首先在我的 Mac 终端上:

easy_install --upgrade google-api-python-client

我使用的是 Mac OS 10.7.4 python 2.7.2

最佳答案

我建议使用 pip 而不是 easy_install。根据this answer对于类似的问题,客户端库和 oauth2client 库可能不兼容。最好使用 pip install -U google-api-python-client(或用于 Python 3 的 pip3)进行升级。

在您完成快速入门后,如果您想查看更长、更“真实世界”的使用 Drive API 的示例,这里是我为您制作的一些视频和博客文章:

(*) - TL;DR:将纯文本文件上传到云端硬盘,导入/转换为 Google 文档格式,然后将该文档导出为 PDF。上面的帖子使用 Drive API v2; this follow-up post描述了将其迁移到 Drive API v3,这里是一个 developer video合并两个“穷人的皈依者”帖子。

关于python - Google Drive SDK 快速入门示例 "ImportError: cannot import name util"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12574307/

相关文章:

python - GTK 聚焦事件

php - 如何读取上传到 Google Drive 的 PDF 文件的内容?

Python 3-谷歌驱动器 API : AttributeError: 'Resource' object has no attribute 'children'

android - 在对 Python 的 Android 后端调用中验证 Id token

python-3.x - 使用 Google API 发送邮件时出错 - "' raw' RFC822 有效负载消息字符串或通过/upload/* URL 上传消息需要”

python - Jenkins:将我的 Python 模块放在 PYTHONPATH 上

python - 如何使用 lxml 将这些 html 标签打印为文本?

python - Django-Rest-Framework POST 对象字段必需

javascript - 通过 API 保存到 Google 云端硬盘

javascript - 使用 Google Drive Rest API 更新文件名