gspread raise RESPONSE踏板

2024-04-19 01:37:22 发布

您现在位置:Python中文网/ 问答频道 /正文

当我尝试使用gspread访问google电子表格时,它总是返回“raise ResponseNotReady()”,我只是按照Github中的用户指南操作,我对httplib和gspread不太熟悉,有没有人能告诉我怎么做,谢谢你的帮助

源代码:

import gspread
from oauth2client.service_account import ServiceAccountCredentials

scope = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']

creds = ServiceAccountCredentials.from_json_keyfile_name('Orait-2018-06-09-200299f40c5e.json', scope)
client = gspread.authorize(creds)
wks = gc.open("sheet1").sheet1

回溯信息:

Traceback (most recent call last):
  File "D:\python\test2.py", line 8, in <module>
    client = gspread.authorize(creds)
  File "C:\Python27\lib\site-packages\gspread\__init__.py", line 38, in authorize
    client.login()
  File "C:\Python27\lib\site-packages\gspread\client.py", line 51, in login
    self.auth.refresh(http)
  File "C:\Python27\lib\site-packages\oauth2client\client.py", line 545, in refresh
    self._refresh(http)
  File "C:\Python27\lib\site-packages\oauth2client\client.py", line 749, in _refresh
    self._do_refresh_request(http)
  File "C:\Python27\lib\site-packages\oauth2client\client.py", line 780, in _do_refresh_request
    body=body, headers=headers)
  File "C:\Python27\lib\site-packages\oauth2client\transport.py", line 282, in request
    connection_type=connection_type)
  File "C:\Python27\lib\site-packages\httplib2\__init__.py", line 1694, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "C:\Python27\lib\site-packages\httplib2\__init__.py", line 1434, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "C:\Python27\lib\site-packages\httplib2\__init__.py", line 1390, in _conn_request
    response = conn.getresponse()
  File "C:\Python27\lib\httplib.py", line 1108, in getresponse
    raise ResponseNotReady()
httplib.ResponseNotReady
[Finished in 22.3s with exit code 1]
[shell_cmd: python -u "D:\python\test2.py"]

Tags: inpyselfclientrequestlibpackagesline