r-spatial / rgee

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

Initializing Google Earth Engine on a Windows 10 machine #282

Closed nikosGeography closed 2 years ago

nikosGeography commented 2 years ago

I saw the issue with initializing GEE in previous posts. I tried everything I found here and on other websites but I just can't fix it. On a Windows 10 machine, I installed the

  1. rgee package and the
  2. google-cloud-sdk (outside of R)
  3. I added the google-cloud-sdk\bin to the system path
  4. I edit the PATHTEXT by adding ;.py.

Nothing seems to work. Below is the code I used.

library(rgee)
library(reticulate)
library(googleCloudStorageR)

ee_Initialize(user = 'nikos.tziokas@gmail.com', drive = T, gcs = T)

I am receiving this msg after running the ee_Initialize() command:

Initializing Google Earth Engine:'gcloud' is not recognized as an internal or external command,
operable program or batch file.
Fetching credentials using gcloud
 Error in py_call_impl(callable, dots$args, dots$keywords) : 
  Exception: gcloud failed. Please check for any errors above and install gcloud if needed. 

The posts I followed to install the rgee library and set up the initialize were:

  1. this #for rgee installation
  2. this #for rgee installation
  3. this #for google-cloud-sdk installation
  4. this #to set up the system path etc
nikosGeography commented 2 years ago

I think I solved the issue. Today, when I tried to re-run the ee_Initialize(user = 'my_email', drive = T, gcs = T) command I received an error saying _Error in ee_connect_to_py(path = ee_current_version, n = 5) : The current Python PATH: C:/Users/Geography/AppData/Local/r-miniconda/envs/r-reticulate/python.exe does not have the Python package "earthengine-api" installed. Are you restarted/terminated. your R session after install miniconda or run ee_install()? If no do it, please try again: ee_install(): To create and set a Python environment with all rgee dependencies. ee_install_setpyenv(): To set a specific Python environment. So I run the ee_install() command and problem solved! I am pretty sure yesterday when I was trying to install the package I used the command ee_install() but anyways.