【发布时间】:2017-11-30 13:07:14
【问题描述】:
所以我从tutorial 运行这段代码,但甚至无法通过授权过程。
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('path/to/oauth.json', scope)
gc = gspread.authorize(credentials)
table = gc.openall()
当我中断进程等待 n 分钟后,我看到它挂起
File "/usr/lib/python3.5/http/client.py", line 1252, in connect
super().connect()
File "/usr/lib/python3.5/http/client.py", line 849, in connect
(self.host,self.port), self.timeout, self.source_address)
File "/usr/lib/python3.5/socket.py", line 702, in create_connection
sock.connect(sa)
KeyboardInterrupt
执行这个方法gspread.authorize(credentials)。
您知道可能是什么问题吗?我尝试了多个 oauth json,所以我想这对 Google 来说不是问题。
我尝试读取 json 并自行传递 args,结果相同。
我从两个不同的 Google 帐户创建了 json 文件,其中一个在公司域中,结果相同。
我正在使用 Python 3.5 和 gspread 0.6.2 在 Ubuntu 16.04、PyCharm 2017.2.4 上运行代码。
编辑:Jupyter Notebook 上出现完全相同的问题。
【问题讨论】:
标签: python json google-sheets google-oauth gspread