GEE python本地环境配置"[WinError 10060]"错误解决方案


title: GEE python本地环境配置"[WinError 10060]"错误
date: 2018-12-10
categories: GEE
tags: python


WinError10060错误

首先参考GEE官方文档进行GEE的Python环境配置

由于某些众所周知的原因,访问GEE云端需要设置网络代理,但是有些时候会发现设置全局代理后仍然不能正常运行


# Import the Earth Engine Python Package

import ee

# 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()出现以下错误:

Exception has occurred: TimeoutError

[WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

解决方案:

# Import the Earth Engine Python Package
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:1080'
os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:1080'

# 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())

需要在代码中设置网络代理地址及端口
e.g. 如果代理地址为 http://127.0.0.1:1080,则需要添加下面两行代码
os.environ[‘HTTP_PROXY’] = ‘http://127.0.0.1:1080
os.environ[‘HTTPS_PROXY’] = ‘http://127.0.0.1:1080
根据自己电脑的代理方式进行设置

代码正常运行输出图像信息如下:

{'type': 'Image', 'bands': [{'id': 'elevation', 'data_type': {'type': 'PixelType', 'precision': 'int', 'min': -32768, 'max': 32767}, 'dimensions': [432000, 144000], 'crs': 'EPSG:4326', 'crs_transform': [0.000833333333333, 0.0, -180.0, 0.0, -0.000833333333333, 60.0]}], 'version': 1494271934303000, 'id': 'srtm90_v4', 'properties': {'system:time_start': 950227200000, 'system:time_end': 951177600000, 'system:asset_size': 18827626666}}

  • 11
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 19
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 19
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值