r-spatial / rgee

Google Earth Engine for R
https://r-spatial.github.io/rgee/
Other
677 stars 146 forks source link

ee_Initalize() Error: Error in py_call_impl(callable, dots$args, dots$keywords) : socket.timeout: timed out #274

Open Wang-yongxiang opened 2 years ago

Wang-yongxiang commented 2 years ago

At submit an issue, please attached the following information of your rgee session:

library(rgee)

# Initialize the Earth Engine module.
ee_Initialize()

# Print metadata for a DEM dataset.
print(ee$Image('USGS/SRTMGL1_003')$getInfo())

Attach your Python (reticulate) configuration:

library(reticulate)
py_config()

python: C:/Users/Spirit_W/AppData/Local/r-miniconda/envs/rgee/python.exe libpython: C:/Users/Spirit_W/AppData/Local/r-miniconda/envs/rgee/python38.dll pythonhome: C:/Users/Spirit_W/AppData/Local/r-miniconda/envs/rgee version: 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 05:59:00) [MSC v.1929 64 bit (AMD64)] Architecture: 64bit numpy: C:/Users/Spirit_W/AppData/Local/r-miniconda/envs/rgee/Lib/site-packages/numpy numpy_version: 1.23.1 ee: C:\Users\Spirit_W\AppData\Local\R-MINI~1\envs\rgee\lib\site-packages\ee__init__.p

NOTE: Python version was forced by RETICULATE_PYTHON

Description

ee_Initialize is failing,The previous stage of the installation process was successfully completed,When I execute the ee_Initialize() command, the browser can pop up and open the gcloud CLI authentication,until the page says "You are now authenticated to the gcloud CLI!"and console text display:“Credentials saved to file: [C:\Users\Spirit_W\AppData\Roaming\gcloud\application_default_credentials.json]”、“These credentials will be used by any library that requests Application Default Credentials (ADC).”,Then after waiting for a while, the console shows:“Fetching credentials using gcloud”and“Successfully saved authorization token.”and“Error in py_call_impl(callable, dots$args, dots$keywords) : socket.timeout: timed out”

What I Did

library(rgee) ee_check() ◉ Python version ✔ [Ok] C:/Users/Spirit_W/AppData/Local/r-miniconda/envs/rgee/python.exe v3.8 ◉ Python packages: ✔ [Ok] numpy ✔ [Ok] earthengine-api ee_clean_credentials() Credentials in C:\Users\Spirit_W/.config/earthengine//ndef has been deleted. ee_Initialize() ── rgee 1.1.4 ──────────────────────────────────────────────────────────────────────────────────────────── earthengine-api 0.1.317 ── ✔ user: not_defined ✔ Initializing Google Earth Engine:Your browser has been opened to visit:

https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=517222506229-vsmmajv00ul0bs7p89v5m89qs8eb9359.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fearthengine+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdevstorage.full_control+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=LPfCI875SsLiJZykDo5RFzSN1are5q&access_type=offline&code_challenge=hZDGM1jyfWI5j5QrUF7n-vTTL2VvP-DySOtOO9Cyh0k&code_challenge_method=S256

Credentials saved to file: [C:\Users\Spirit_W\AppData\Roaming\gcloud\application_default_credentials.json]

These credentials will be used by any library that requests Application Default Credentials (ADC). Fetching credentials using gcloud

Successfully saved authorization token. Error in py_call_impl(callable, dots$args, dots$keywords) : socket.timeout: timed out

kongdd commented 2 years ago

This is the problem of VPN proxy. I found two solutions for RStudio and VScode respectively.

The following solution not working. Because we need to set proxy before R start, other than after. See https://github.com/r-spatial/rgee/issues/73#issuecomment-1186549194 for details.

Sys.setenv(https_proxy="http://127.0.0.1:1081")
Sys.setenv(http_proxy="http://127.0.0.1:1081")