r-spatial / rgee

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

rgee does not "remember" the python environment #345

Open andrew-caudillo opened 1 year ago

andrew-caudillo commented 1 year ago

rgee forgets the Python environment it installed dependencies (numpy and earthengine-api) to. When running ee_Initialize(), it suggests running ee_install(). However, reinstalling ee temporarily fixes the issue. To resolve it, you need to use reticulate to set the directory rgee expects (conda .exe file) every time you use rgee. This fix may help others with the same issue; my colleagues also encountered it.

andrew-caudillo commented 9 months ago

The fix I implemented in August just began to fail yesterday, 13 November 2023. I am having a very difficult time getting rgee to install. I have set the python environment, but ee_install() fails to recognize it. I had to restart my machine 3 times and terminate R about 5 times. When ee_install() finally worked, it said rgee would store the necessary files in my python environment, but then fails to recognize the environment (or that I even have python on my machine). I am confused as to why rgee fails to store the python path it used when installing in its directory or something similar.

ee_check() Error in ee_check_python(quiet = quiet) : Unable to find a Python version, you will need to fix before run rgee::ee_Initialize(). For more details run reticulate::py_available()

I again have to manually set the path to python before running any rgee function to fix this recurring issue. Additionally, the package will sometimes initialize without issue and other times not even initialize due to a python environment "not existing", even though it does.

andrew-caudillo commented 9 months ago

I'm getting this error again, about a month later on 12/8/2023. I have set the environment using reticulate, I have earth engine credentials, and earthengine-api and numpy are installed in my python environment. Setting a clean py_env does not always work- it takes me about 5 tries to finally get rgee to work, but it does not result in a consistent fix. This issue is continually frustrating.

Error in ee_connect_to_py(path = ee_current_version, n = 5) : The current Python PATH: C:/...rgee/python.exe does not have the Python package "earthengine-api" installed. Do you restarted/terminated your R session after install miniconda or run ee_install()? If this is not the case, try:

ee_install_upgrade(): Install the latest Earth Engine Python version. reticulate::use_python(): Refresh your R session and manually set the Python environment with all rgee dependencies. ee_install(): To create and set a Python environment with all rgee dependencies. ee_install_set_pyenv(): To set a specific Python environment.

after "successfully installing" rgee, I get this error after restarting/terminating my R session. rgee::ee_check() Error in ee_check_python(quiet = quiet) : Unable to find a Python version, you will need to fix before run rgee::ee_Initialize(). For more details run reticulate::py_available()

This is the cycle I have to go through multiple times until rgee randomly does install correctly.

andrew-caudillo commented 9 months ago

Once I closed Rstudio and re-opened, rgee does not recognize that I have numpy installed, even though it successfully installed numpy and earthengine-api a few days ago.

Error in py_module_import(module, convert = convert) : ModuleNotFoundError: No module named 'ee'

rgee::ee_check() (*) Python version v [Ok] C:/Program Files/Conda/envs/rgee/python.exe v3.8 v [X] numpy not installed