GoogleEarthEngine的Python环境安装出错
ee.Initialize()
Traceback (most recent call last):
File "" , line 1, in <module>
File "D:\Anaconda3\lib\site-packages\ee\__init__.py", line 123, in Initialize
http_transport=http_transport)
File "D:\Anaconda3\lib\site-packages\ee\data.py", line 210, in initialize
_install_cloud_api_resource()
File "D:\Anaconda3\lib\site-packages\ee\data.py", line 287, in _install_cloud_api_resource
http_transport=_http_transport)
File "D:\Anaconda3\lib\site-packages\ee\_cloud_api_utils.py", line 149, in build_cloud_resource
model=alt_model)
File "D:\Anaconda3\lib\site-packages\googleapiclient\_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "D:\Anaconda3\lib\site-packages\googleapiclient\discovery.py", line 246, in build
requested_url, discovery_http, cache_discovery, cache, developerKey
File "D:\Anaconda3\lib\site-packages\googleapiclient\discovery.py", line 305, in _retrieve_discovery_doc
resp, content = http.request(actual_url)
File "D:\Anaconda3\lib\site-packages\google_auth_httplib2.py", line 187, in request
self._request, method, uri, request_headers)
File "D:\Anaconda3\lib\site-packages\google\auth\credentials.py", line 124, in before_request
self.refresh(request)
File "D:\Anaconda3\lib\site-packages\google\oauth2\credentials.py", line 210, in refresh
self._scopes,
File "D:\Anaconda3\lib\site-packages\google\oauth2\_client.py", line 248, in refresh_grant
response_data = _token_endpoint_request(request, token_uri, body)
File "D:\Anaconda3\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 "D:\Anaconda3\lib\site-packages\google_auth_httplib2.py", line 116, in __call__
url, method=method, body=body, headers=headers, **kwargs)
File "D:\Anaconda3\lib\site-packages\httplib2\__init__.py", line 1994, in request
cachekey,
File "D:\Anaconda3\lib\site-packages\httplib2\__init__.py", line 1651, in _request
conn, request_uri, method, body, headers
File "D:\Anaconda3\lib\site-packages\httplib2\__init__.py", line 1557, in _conn_request
conn.connect()
File "D:\Anaconda3\lib\site-packages\httplib2\__init__.py", line 1391, in connect
raise socket_err
File "D:\Anaconda3\lib\site-packages\httplib2\__init__.py", line 1324, in connect
sock.connect((self.host, self.port))
TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
运行时报错 TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。,后来搜到了很多比如关闭防火墙,修改hosts文件这些,都没用,最后参考https://zhuanlan.zhihu.com/p/50717864解决,方法为在命令行输入,下面的命令,地址为自己的代理地址,需要注意的是这种设置代理方式只能针对当前窗口有效
(base) C:\Users\67231>set http_proxy=http://127.0.0.1:10809
(base) C:\Users\67231>set https_proxy=http://127.0.0.1:10809
import ee
import os
# update the proxy settings
# os.environ['HTTP_PROXY'] = 'my_proxy_id:proxy_port'
# os.environ['HTTPS_PROXY'] = 'my_proxy_id:proxy_port'
os.environ['HTTP_PROXY'] = 'http://127.0.0.1:10809'
os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:10809'
# Initialize the Earth Engine object, using the authentication credentials.
ee.Initialize()
# Print the information for an image asset.
image = ee.Image('srtm90_v4')
print(image.getInfo())
ee.Initialize()
Traceback (most recent call last):
File "D:\Anaconda3\lib\site-packages\ee\data.py", line 345, in _execute_cloud_call
return call.execute(num_retries=num_retries)
File "D:\Anaconda3\lib\site-packages\googleapiclient\_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "D:\Anaconda3\lib\site-packages\googleapiclient\http.py", line 907, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/algorithms?prettyPrint=false&alt=json returned "Permission denied.">
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "" , line 1, in <module>
File "D:\Anaconda3\lib\site-packages\ee\__init__.py", line 125, in Initialize
ApiFunction.initialize()
File "D:\Anaconda3\lib\site-packages\ee\apifunction.py", line 154, in initialize
signatures = data.getAlgorithms()
File "D:\Anaconda3\lib\site-packages\ee\data.py", line 1052, in getAlgorithms
return _cloud_api_utils.convert_algorithms(_execute_cloud_call(call))
File "D:\Anaconda3\lib\site-packages\ee\data.py", line 347, in _execute_cloud_call
raise _translate_cloud_exception(e)
ee.ee_exception.EEException: Permission denied.
忘记了进行注册。https://signup.earthengine.google.com
注册后便可以使用了。