我已经在这个问题上苦苦挣扎了一段时间,并且搜寻了互联网,但是仍然无法解决它。
我正在尝试运行python脚本以从工作中的本地计算机访问google工作表(因此可能是防火墙问题)。每当我连接到来宾网络时,脚本都可以正常工作。每当我尝试使用工作内部网络(带有或不带有代理设置)时,都会出现以下错误:
***Traceback (most recent call last):
File "C:\Python36-32\lib\site-packages\httplib2\__init__.py", line 995, in _conn_request
conn.connect()
File "C:\Python36-32\lib\http\client.py", line 1392, in connect
super().connect()
File "C:\Python36-32\lib\http\client.py", line 936, in connect
(self.host,self.port), self.timeout, self.source_address)
File "C:\Python36-32\lib\socket.py", line 704, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Python36-32\lib\socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11004] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.1\helpers\pydev\pydevd.py", line 1664, in <module>
main()
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.1\helpers\pydev\pydevd.py", line 1658, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.1\helpers\pydev\pydevd.py", line 1068, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.1\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Git/datalab-notebooks/2017-vin-profitability/US/Finance_Mapping_test.py", line 23, in <module>
client = gspread.authorize(credentials)
File "C:\Python36-32\lib\site-packages\gspread\__init__.py", line 38, in authorize
client.login()
File "C:\Python36-32\lib\site-packages\gspread\client.py", line 52, in login
self.auth.refresh(http)
File "C:\Python36-32\lib\site-packages\oauth2client\client.py", line 668, in refresh
self._refresh(http.request)
File "C:\Python36-32\lib\site-packages\oauth2client\client.py", line 873, in _refresh
self._do_refresh_request(http_request)
File "C:\Python36-32\lib\site-packages\oauth2client\client.py", line 905, in _do_refresh_request
self.token_uri, method='POST', body=body, headers=headers)
File "C:\Python36-32\lib\site-packages\httplib2\__init__.py", line 1322, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "C:\Python36-32\lib\site-packages\httplib2\__init__.py", line 1072, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "C:\Python36-32\lib\site-packages\httplib2\__init__.py", line 1002, in _conn_request
raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
httplib2.ServerNotFoundError: Unable to find the server at accounts.google.com***
经过一番研究,我觉得这是由于我的代理设置引起的,但我无法弄清楚该如何解决。我也了解python库袜子可能会有所帮助,但我又一次陷入困境
任何帮助将不胜感激
预先感谢