连接尝试失败,因为一段时间后连接方未正确响应或连接的主机未响应。
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('C:/Users/robin/Desktop/work/secret.json', scope)
client = gspread.authorize(creds)
sheet = client.open("python to sheets").sheet1
错误:
Traceback (most recent call last):
File "c:/Users/robin/Desktop/work/google.py", line 9, in <module>
client = gspread.authorize(creds)
File "C:\Python35\lib\site-packages\gspread\__init__.py", line 38, in authorize
client.login()
File "C:\Python35\lib\site-packages\gspread\client.py", line 51, in login
self.auth.refresh(http)
File "C:\Python35\lib\site-packages\oauth2client\client.py", line 545, in refresh
self._refresh(http)
File "C:\Python35\lib\site-packages\oauth2client\client.py", line 749, in _refresh
self._do_refresh_request(http)
File "C:\Python35\lib\site-packages\oauth2client\client.py", line 780, in _do_refresh_request
body=body, headers=headers)
File "C:\Python35\lib\site-packages\oauth2client\transport.py", line 282, in request
connection_type=connection_type)
File "C:\Python35\lib\site-packages\httplib2\__init__.py", line 1976, in request
cachekey,
File "C:\Python35\lib\site-packages\httplib2\__init__.py", line 1640, in _request
conn, request_uri, method, body, headers
File "C:\Python35\lib\site-packages\httplib2\__init__.py", line 1546, in _conn_request
conn.connect()
File "C:\Python35\lib\site-packages\httplib2\__init__.py", line 1384, in connect
raise socket_err
File "C:\Python35\lib\site-packages\httplib2\__init__.py", line 1317, in connect
sock.connect((self.host, self.port))
TimeoutError: [WinError 10060]