Gspread 卡在授权上
Gspread stuck on authorization
所以我 运行 来自 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 jsons,所以我想这对 Google 来说不是问题。
我尝试阅读 json 并自行传递参数,结果相同。
我从两个不同的 Google 帐户创建了 json 文件,其中一个在公司域中,结果相同。
我是 运行 Ubuntu 16.04 上的代码,PyCharm 2017.2.4,Python 3.5 和 gspread 0.6.2。
编辑:Jupyter Notebook 上出现完全相同的问题。
好的,它有效,但我实际上不得不等待 10 多分钟。人们 运行 在 youtube 上使用完全相同的代码会立即看到输出。不过,如果您知道延迟的原因或如何调试此套接字问题,请告诉我。
所以我 运行 来自 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 jsons,所以我想这对 Google 来说不是问题。
我尝试阅读 json 并自行传递参数,结果相同。
我从两个不同的 Google 帐户创建了 json 文件,其中一个在公司域中,结果相同。
我是 运行 Ubuntu 16.04 上的代码,PyCharm 2017.2.4,Python 3.5 和 gspread 0.6.2。
编辑:Jupyter Notebook 上出现完全相同的问题。
好的,它有效,但我实际上不得不等待 10 多分钟。人们 运行 在 youtube 上使用完全相同的代码会立即看到输出。不过,如果您知道延迟的原因或如何调试此套接字问题,请告诉我。