Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in ee_Initialize() : reticulate refuse to connect with rgee #91

Closed
pjaguirreh opened this issue Aug 11, 2020 · 19 comments
Closed
Labels
good first issue Good for newcomers

Comments

@pjaguirreh
Copy link

Hi!

I'm getting the following error when trying to execute the ee_Initialize() command: Error in ee_Initialize() : reticulate refuse to connect with rgee.

I followed the instructions from the rgee site and when I run ee_check() I get the following message, I don't know if it's related:

ee_check()
(*) Python version
√ [Ok] C:/Users/pjagu/AppData/Local/r-miniconda/envs/rgee/python.exe v3.8
[X] earthengine-api not installed

Any guidance?
Thanks

sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=Spanish_Chile.1252 LC_CTYPE=Spanish_Chile.1252 LC_MONETARY=Spanish_Chile.1252
[4] LC_NUMERIC=C LC_TIME=Spanish_Chile.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] reticulate_1.16 rgee_1.0.4

loaded via a namespace (and not attached):
[1] compiler_4.0.2 magrittr_1.5 assertthat_0.2.1 Matrix_1.2-18 cli_2.0.2 tools_4.0.2
[7] glue_1.4.1 rstudioapi_0.11 rappdirs_0.3.1 Rcpp_1.0.5 crayon_1.3.4 fansi_0.4.1
[13] grid_4.0.2 jsonlite_1.7.0 lattice_0.20-41

@LouiseLeroux
Copy link

Hi,

I just found the solution! Apparently this come from an update of Conda version. You have just to update your conda version with the following :conda update -n base conda. It works for me.

@csaybar
Copy link
Collaborator

csaybar commented Aug 11, 2020

Hi @pjaguirreh your conda env looks good. It seems the problem is that ee_install (for some reason) does not install the earthengine-api Python API, maybe as @LouiseLeroux says, related with your conda version. You can install it manually as follow:

rgee::ee_install_upgrade()

If it doesn't work try:

conda install --name rgee earthengine-api

If you persist presenting this problem please attached us your rgee env:

Sys.getenv("EARTHENGINE_PYTHON")
Sys.getenv("EARTHENGINE_ENV")

@csaybar csaybar added the good first issue Good for newcomers label Aug 11, 2020
@pjaguirreh
Copy link
Author

Tried both suggestions and didn't work (I'm attaching two related images).

Regarding your request:

Sys.getenv("EARTHENGINE_PYTHON")
[1] "C:\Users\pjagu\AppData\Local\r-miniconda\envs\rgee\python.exe"
Sys.getenv("EARTHENGINE_ENV")
[1] "rgee"

image

image

@csaybar
Copy link
Collaborator

csaybar commented Aug 11, 2020

Please attached us the following information:

library(rgee)
library(reticulate)
earthengine_python <- Sys.getenv("EARTHENGINE_PYTHON", unset = NA)
Sys.setenv(RETICULATE_PYTHON = earthengine_python)
reticulate::py_config()

@pjaguirreh
Copy link
Author

image

@csaybar
Copy link
Collaborator

csaybar commented Aug 11, 2020

Please, Can you run again? I updated the message

library(rgee)
library(reticulate)
earthengine_python <- Sys.getenv("EARTHENGINE_PYTHON", unset = NA)
Sys.setenv(RETICULATE_PYTHON = earthengine_python)
reticulate::py_config()

OBS: You need to restart R before to run again reticulate::py_config

@pjaguirreh
Copy link
Author

image

ps: Yes, I'm restarting R each time I try a new instruction

@ryali93
Copy link
Collaborator

ryali93 commented Aug 12, 2020

Hi, I solved the problem terminating my R session. After terminated your R session, can you attached us again the following:

library(rgee)
ee_check()
ee_Initialize()
reticulate::py_config()

image

@pjaguirreh
Copy link
Author

Thank you all for the time. I did it and still the same problem

image

@csaybar
Copy link
Collaborator

csaybar commented Aug 12, 2020

Hi @pjaguirreh really strange, but for some reason, you have miniconda with Python36 and Python38.
#91 (comment)
#91 (comment)
Please can you share with us a traceback of your error?

ee_Initialize()
traceback()

Do not forget to restart your R session.

@pjaguirreh
Copy link
Author

image

@csaybar
Copy link
Collaborator

csaybar commented Aug 12, 2020

Ok, it helps. Can you run the follows please, if you get an error please share with us the traceback()

library(rgee)

earthengine_python <- Sys.getenv("EARTHENGINE_PYTHON", unset = NA)
print(earthengine_python)
Sys.setenv(RETICULATE_PYTHON = earthengine_python)
ee_current_version <- system.file("python/ee_utils.py", package = "rgee")
ee_utils <- rgee:::ee_source_python(ee_current_version)
print(ee_utils$ee$'__version__')

OBS: You need to restart R before to run rgee:::ee_source_python

@pjaguirreh
Copy link
Author

Apparently that worked!

But if I start a new R session I have to run again the code you attach.

image

@pjaguirreh
Copy link
Author

And I can't run it after I "do the check" because I get the following:

image

But if I restart the session and run again the code you attach it works once again.

@csaybar
Copy link
Collaborator

csaybar commented Aug 12, 2020

HI @pjaguirreh, I really do not understand why you get refuse error. Does the code below work for you?

earthengine_python <- Sys.getenv("EARTHENGINE_PYTHON", unset = NA)
print(earthengine_python)
Sys.setenv(RETICULATE_PYTHON = earthengine_python)
ee_current_version <- system.file("python/ee_utils.py", package = "rgee")
ee_utils <- try(rgee:::ee_source_python(ee_current_version), silent = TRUE)
con_reticulate_counter <- 0
while (any(class(ee_utils) %in% "try-error")) {
  ee_utils <- try(rgee:::ee_source_python(ee_current_version), 
                  silent = TRUE)
  con_reticulate_counter <- con_reticulate_counter + 1
  if (con_reticulate_counter == 4) {
    stop("reticulate refuse to connect with rgee")
  }
}

@pjaguirreh
Copy link
Author

Apparently, if I just don't run "ee_check()" there's no problem with "ee_Initialize()". I was already able to run the examples in the rgee site.

ee_Initialize()
-- rgee 1.0.4 --------------------------------------- earthengine-api 0.1.229 --
√ email: not_defined
√ Initializing Google Earth Engine: DONE!
√ Earth Engine user: users/gee_earth_engine

@csaybar
Copy link
Collaborator

csaybar commented Aug 12, 2020

Thanks, happy to see rgee working, thanks to notifying us, we study in deeper the problem with ee_check().

@DANYPORRAS
Copy link

ee_Initialize('DanielPorras')
Error in ee_connect_to_py(path = ee_current_version, n = 5) :
The current Python PATH: C:/Users/DANIEL/AppData/Local/r-miniconda/envs/rgee/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_set_pyenv(): To set a specific Python environment.

@h-a-graham
Copy link

Thanks to the suggestions above, the following solved the issue for me:

earthengine_python <- Sys.getenv("EARTHENGINE_PYTHON", unset = NA)
Sys.setenv(RETICULATE_PYTHON = earthengine_python)
.rs.restartR()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

6 participants