GEE环境配置|GEE环境配置错误修正(TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。)

在Windows10 系统下安装GEE环境
具体报错的内容如下:
调用ee.Initialize()时候,python报如下错误
TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
自己的本机名字全是英文格式,一开始以为是自己网络故障,但发现不是。
具体的错误如下所示:

Traceback (most recent call last): File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 160, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\connection.py", line 84, in create_connection raise err File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\connection.py", line 74, in create_connection sock.connect(sa) TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。During handling of the above exception, another exception occurred:Traceback (most recent call last): File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\httplib2shim\__init__.py", line 148, in _conn_request decode_content=decode) File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\request.py", line 80, in request method, url, fields=fields, headers=headers, **urlopen_kw File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\request.py", line 171, in request_encode_body return self.urlopen(method, url, **extra_kw) File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\poolmanager.py", line 336, in urlopen response = conn.urlopen(method, u.request_uri, **kw) File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 725, in urlopen method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\retry.py", line 379, in increment raise six.reraise(type(error), error, _stacktrace) File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\packages\six.py", line 735, in reraise raise value File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 677, in urlopen chunked=chunked, File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 381, in _make_request self._validate_conn(conn) File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 976, in _validate_conn conn.connect() File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 308, in connect conn = self._new_conn() File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 172, in _new_conn self, "Failed to establish a new connection: %s" % e urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。During handling of the above exception, another exception occurred:Traceback (most recent call last): File "C:\Users\male\Desktop\test.py", line 5, in ee.Initialize() File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\ee\__init__.py", line 123, in Initialize http_transport=http_transport) File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\ee\data.py", line 210, in initialize _install_cloud_api_resource() File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\ee\data.py", line 287, in _install_cloud_api_resource http_transport=_http_transport) File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\ee\_cloud_api_utils.py", line 149, in build_cloud_resource model=alt_model) File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\googleapiclient\_helpers.py", line 134, in positional_wrapper return wrapped(*args, **kwargs) File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\googleapiclient\discovery.py", line 246, in build requested_url, discovery_http, cache_discovery, cache, developerKey File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\googleapiclient\discovery.py", line 305, in _retrieve_discovery_doc resp, content = http.request(actual_url) File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\google_auth_httplib2.py", line 187, in request self._request, method, uri, request_headers) File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\google\auth\credentials.py", line 124, in before_request self.refresh(request) File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\google\oauth2\credentials.py", line 183, in refresh self._scopes, File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\google\oauth2\_client.py", line 248, in refresh_grant response_data = https://www.it610.com/article/_token_endpoint_request(request, token_uri, body) File"C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\google\oauth2\_client.py", line 105, in _token_endpoint_request response = request(method="POST", url=token_uri, headers=headers, body=body) File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\google_auth_httplib2.py", line 116, in __call__ url, method=method, body=body, headers=headers, **kwargs) File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\httplib2\__init__.py", line 1994, in request cachekey, File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\httplib2\__init__.py", line 1651, in _request conn, request_uri, method, body, headers File "C:\Users\male\AppData\Local\Programs\Python\Python37\lib\site-packages\httplib2shim\__init__.py", line 154, in _conn_request raise _map_exception(e) socket.timeout: timed out

解决方法:
【GEE环境配置|GEE环境配置错误修正(TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。)】需要将如下的代码在命令行中设置
C:\Users\male>set http_proxy=http://127.0.0.1:1080
C:\Users\male>set https_proxy=http://127.0.0.1:1080
将地址换成你自己的代理地址。
GEE环境配置|GEE环境配置错误修正(TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。)
文章图片

该代理方式只针对于当前的窗口,当离开了该窗口依然是无效的。



    推荐阅读