title: GEE python本地环境配置"[WinError 10060]"错误
date: 2018-12-10
categories: GEE
tags: python
WinError10060错误
首先参考GEE官方文档进行GEE的Python环境配置
由于某些众所周知的原因,访问GEE云端需要设置网络代理,但是有些时候会发现设置全局代理后仍然不能正常运行
# Import the Earth Engine Python Packageimport 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’
根据自己电脑的代理方式进行设置
代码正常运行输出图像信息如下:
【python|GEE python本地环境配置"[WinError 10060]"错误解决方案】
{'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}}
推荐阅读
- 推荐系统论文进阶|CTR预估 论文精读(十一)--Deep Interest Evolution Network(DIEN)
- Python专栏|数据分析的常规流程
- Python|Win10下 Python开发环境搭建(PyCharm + Anaconda) && 环境变量配置 && 常用工具安装配置
- Python绘制小红花
- Pytorch学习|sklearn-SVM 模型保存、交叉验证与网格搜索
- OpenCV|OpenCV-Python实战(18)——深度学习简介与入门示例
- python|8. 文件系统——文件的删除、移动、复制过程以及链接文件
- 爬虫|若想拿下爬虫大单,怎能不会逆向爬虫,价值过万的逆向爬虫教程限时分享
- 分布式|《Python3网络爬虫开发实战(第二版)》内容介绍
- java|微软认真聆听了开源 .NET 开发社区的炮轰( 通过CLI 支持 Hot Reload 功能)