超时错误-如何修复Python中Google电子表格的Google drive api

超时错误-如何修复Python中Google电子表格的Google drive api,python,google-drive-api,timeout,macos-mojave,Python,Google Drive Api,Timeout,Macos Mojave,我在运行Python代码时遇到了一个TimeoutError 我真的很想连接到谷歌电子表格。 我的系统是莫哈韦,不知道它是否影响。谢谢你的帮助。我遇到的问题和你完全一样。我想问题在于网络代理。我尝试迁移到V4API并切换到pygsheet。问题依然存在。你也在中国吗?问题可能来自与谷歌服务器的VPN连接。希望有人能证实这个问题。 --------------------------------------------------------------------------- Timeout

我在运行Python代码时遇到了一个TimeoutError


我真的很想连接到谷歌电子表格。
我的系统是莫哈韦,不知道它是否影响。谢谢你的帮助。

我遇到的问题和你完全一样。我想问题在于网络代理。我尝试迁移到V4API并切换到pygsheet。问题依然存在。你也在中国吗?问题可能来自与谷歌服务器的VPN连接。希望有人能证实这个问题。
---------------------------------------------------------------------------
TimeoutError                              Traceback (most recent call last)
<ipython-input-6-06414818a9b8> in <module>
      6 credentials = ServiceAccountCredentials.from_json_keyfile_name('test.json', scope)
      7 
----> 8 gc = gspread.authorize(credentials)
      9 
     10 wks = gc.open("reivewapi").sheet1

~/miniconda3/envs/udacity/lib/python3.6/site-packages/gspread/__init__.py in authorize(credentials, client_class)
     36     """
     37     client = client_class(auth=credentials)
---> 38     client.login()
     39     return client

~/miniconda3/envs/udacity/lib/python3.6/site-packages/gspread/client.py in login(self)
     49 
     50             http = httplib2.Http()
---> 51             self.auth.refresh(http)
     52 
     53         self.session.headers.update({

~/miniconda3/envs/udacity/lib/python3.6/site-packages/oauth2client/client.py in refresh(self, http)
    543                   request.
    544         """
--> 545         self._refresh(http)
    546 
    547     def revoke(self, http):

~/miniconda3/envs/udacity/lib/python3.6/site-packages/oauth2client/client.py in _refresh(self, http)
    747         """
    748         if not self.store:
--> 749             self._do_refresh_request(http)
    750         else:
    751             self.store.acquire_lock()

~/miniconda3/envs/udacity/lib/python3.6/site-packages/oauth2client/client.py in _do_refresh_request(self, http)
    778         resp, content = transport.request(
    779             http, self.token_uri, method='POST',
--> 780             body=body, headers=headers)
    781         content = _helpers._from_bytes(content)
    782         if resp.status == http_client.OK:

~/miniconda3/envs/udacity/lib/python3.6/site-packages/oauth2client/transport.py in request(http, uri, method, body, headers, redirections, connection_type)
    280     return http_callable(uri, method=method, body=body, headers=headers,
    281                          redirections=redirections,
--> 282                          connection_type=connection_type)
    283 
    284 

~/miniconda3/envs/udacity/lib/python3.6/site-packages/httplib2/__init__.py in request(self, uri, method, body, headers, redirections, connection_type)
   1924                         headers,
   1925                         redirections,
-> 1926                         cachekey,
   1927                     )
   1928         except Exception as e:

~/miniconda3/envs/udacity/lib/python3.6/site-packages/httplib2/__init__.py in _request(self, conn, host, absolute_uri, request_uri, method, body, headers, redirections, cachekey)
   1593 
   1594         (response, content) = self._conn_request(
-> 1595             conn, request_uri, method, body, headers
   1596         )
   1597 

~/miniconda3/envs/udacity/lib/python3.6/site-packages/httplib2/__init__.py in _conn_request(self, conn, request_uri, method, body, headers)
   1499             try:
   1500                 if conn.sock is None:
-> 1501                     conn.connect()
   1502                 conn.request(method, request_uri, body, headers)
   1503             except socket.timeout:

~/miniconda3/envs/udacity/lib/python3.6/site-packages/httplib2/__init__.py in connect(self)
   1354             break
   1355         if not self.sock:
-> 1356             raise socket_err
   1357 
   1358 

~/miniconda3/envs/udacity/lib/python3.6/site-packages/httplib2/__init__.py in connect(self)
   1287                 if has_timeout(self.timeout):
   1288                     sock.settimeout(self.timeout)
-> 1289                 sock.connect((self.host, self.port))
   1290 
   1291                 self.sock = self._context.wrap_socket(sock, server_hostname=self.host)

TimeoutError: [Errno 60] Operation timed out

import gspread
from oauth2client.service_account import ServiceAccountCredentials

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

credentials = ServiceAccountCredentials.from_json_keyfile_name('test.json', scope)

gc = gspread.authorize(credentials)

wks = gc.open("reivewapi").sheet1
reviews = sheet.get_all_records()