GSpread ImportError:没有名为oauth2client.service_account的模块

Rya*_*rdt 9 python google-api-python-client gspread google-app-engine-python

好的我正在跟随"成为技术营销人员"课程,我正在尝试学习如何使用GSpread管理Google Spreadsheets.我已经按照http://gspread.readthedocs.io/en/latest/oauth2.html上的文档进行了操作.我按照上面第二个URL中的步骤操作了一个包含以下代码的文档:

import gspread
from oauth2client.service_account import ServiceAccountCredentials

scope = ['https://spreadsheets.google.com/feeds']

credentials = ServiceAccountCredentials.from_json_keyfile_name('DFS Google Sheets Data Imports-7205de852ff7.json', scope)

gc = gspread.authorize(credentials)

wks = gc.open("Authority Scraper").sheet1
wks.update_cell(1,2,"Hello World!")
Run Code Online (Sandbox Code Playgroud)

从那里我得到了终端中的错误:来自oauth2client.service_account import ServiceAccountCredentials ImportError:没有名为oauth2client.service_account的模块

终端错误打印输出

有人请帮帮我.其他没有名为oath2client.service_account的模块的答案对我不起作用.谢谢!

kev*_*rsi 16

运行此命令对我有用 - sudo pip install --upgrade oauth2client

从oauth2client库github repo 得到了这个


Jac*_*din 3

根据这次讨论

这是因为 OS X El Capitan 附带了六个已安装的 1.4.1,当它尝试卸载它时,它没有权限这样做,因为系统完整性保护甚至不允许 root 修改这些目录。

在答案中提到的几个解决方法中,可能值得尝试pip install --ignore-installed six避免尝试卸载系统six软件包。