r-spatial / rgee

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

Error in py_call_impl(callable, dots$args, dots$keywords) #290

Closed POTCHARAARIYA closed 1 year ago

POTCHARAARIYA commented 2 years ago

rgee version: 1.1.4 R version: 4.2.1 Operating System: macOS M1 Initialize the Earth Engine module. ee_Initialize()

── rgee 1.1.4 ─────────────── earthengine-api 0.1.324 ── ✔ user: not_defined ✔ Google Drive credentials: FOUND ✔ Initializing Google Earth Engine:sh: gcloud: command not found 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.

I already install gcloud but can't set PATH ,what should I do? I don't understand issue #282

I'm trying to check user status. It show

pochara788 EE ✖ GCS ✔ GD ✖

Help me, what should I do?

LucasXin1 commented 2 years ago

I encountered the same problem

csaybar commented 2 years ago

Sorry for the late reply,

I added a new function ("ee_check_gcloud") ... See ?ee_check

Besides, from v0.1.304, earthengine-api (Python side) requires gcloud to manage authentication (see ee_Authenticate).

https://cloud.google.com/sdk/docs/install

LucasXin1 commented 2 years ago

thanks,I have already downloaded gcloud CLI, but i encountered a new problem,shown in the picture.May I ask if this is due to the incorrect setting of my net work vpn? how can I do?

Besides,can I finish the initialization before I apply for the google cloud account? Thanks!

------------------ 原始邮件 ------------------ 发件人: "r-spatial/rgee" @.>; 发送时间: 2022年10月8日(星期六) 晚上7:18 @.>; 抄送: "Xin @.**@.>; 主题: Re: [r-spatial/rgee] Error in py_call_impl(callable, dots$args, dots$keywords) (Issue #290)

Sorry for the late reply,

I added a new function ("ee_check_gcloud") ... See ?ee_check

Besides, from v0.1.304, earthengine-api (Python side) requires gcloud to manage authentication (see ee_Authenticate).

https://cloud.google.com/sdk/docs/install

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

POTCHARAARIYA commented 2 years ago

@csaybar

ee_check() ◉ Python version ✔ [Ok] /Users/potchara/.virtualenvs/rgee/bin/python v3.10 ◉ Python packages: ✔ [Ok] numpy ✔ [Ok] earthengine-api Error in ee_check_gcloud() : gcloud failed [os.system('gcloud --help')]. Please check for any errors above and install gcloud if needed (https://cloud.google.com/sdk/docs/install).

csaybar commented 2 years ago

Hi @LucasXin1, sorry i don't know how to solve the VPN earthengine errors. Maybe you can ask/search in GtEE google groups. https://groups.google.com/g/google-earth-engine-developers. As far as I understand, you do not need to "apply" for a Google Cloud account.

@POTCHARAARIYA yes, unfortunately, you also need to install gcloud CLI for use Python or R gee API.

LucasXin1 commented 2 years ago

thank you very much!

---Original--- From: @.> Date: Mon, Oct 10, 2022 12:43 PM To: @.>; Cc: @.**@.>; Subject: Re: [r-spatial/rgee] Error in py_call_impl(callable, dots$args,dots$keywords) (Issue #290)

Hi @LucasXin1, sorry i don't know how to solve the VPN earthengine errors. Maybe you can ask/search in GtEE google groups. https://groups.google.com/g/google-earth-engine-developers. As far as I understand, you do not need to "apply" for a Google Cloud account.

@POTCHARAARIYA yes, unfortunately, you also need to install gcloud CLI for use Python or R gee API.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

POTCHARAARIYA commented 2 years ago

Hi @LucasXin1, sorry i don't know how to solve the VPN earthengine errors. Maybe you can ask/search in GtEE google groups. https://groups.google.com/g/google-earth-engine-developers. As far as I understand, you do not need to "apply" for a Google Cloud account.

@POTCHARAARIYA yes, unfortunately, you also need to install gcloud CLI for use Python or R gee API.

I'm already installed gcloud but it cannot use rgee.

── rgee 1.1.5 ─────────────────────────────────────────────────────────────────── earthengine-api 0.1.326 ── ✔ user: not_defined ✔ Google Drive credentials:Auto-refreshing stale OAuth token. ✔ Google Drive credentials: FOUND ✔ Initializing Google Earth Engine:sh: gcloud: command not found 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.

csaybar commented 2 years ago

can u run?

system("gcloud --help")
POTCHARAARIYA commented 2 years ago
system("gcloud --help")

On Terminal or R studio?

csaybar commented 2 years ago

In your R ENV.

base::system("gcloud --help")

POTCHARAARIYA commented 2 years ago

In your R ENV.

system("gcloud --help") sh: gcloud: command not found Warning message: In system("gcloud --help") : error in running command

T_T

csaybar commented 2 years ago

mmm, it seems that you have to define manually the gcloud CLI path. Try something like this:

# 1. Restart your R system
# 2. load rgee
library(rgee)
# 3.  Set gcloud path (for Linux users)
Sys.setenv(PATH=sprintf("%s:%s", Sys.getenv("PATH"), sprintf("%s/google-cloud-sdk/bin/", Sys.getenv("HOME"))))
# 4. Check gcloud
ee_check_gcloud()
# 5. if ee_check_gcloud work ...  rgee will work!
ee_Initialize()
POTCHARAARIYA commented 2 years ago
ee_check_gcloud()

── rgee 1.1.5 ─────────────────────────────────────────────────────────────────── earthengine-api 0.1.326 ── ✔ user: not_defined ✔ Google Drive credentials: FOUND ✔ 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=8durodfXdOAfWIkgi5fXGwdYHxsKNC&access_type=offline&code_challenge=-x-rKvqovEayVbXUC7Lf0l8X0q8DXhluzCowGYodvA4&code_challenge_method=S256

Credentials saved to file: [/Users/potchara/.config/gcloud/application_default_credentials.json]

These credentials will be used by any library that requests Application Default Credentials (ADC). ✔ Initializing Google Earth Engine: DONE! ✔ Earth Engine account: users/pochara788

It's DONE!!!

Thank you So much!!!

Phoenix11-cell commented 1 year ago

@POTCHARAARIYA Hello, I seem to have met the same as you, but I am a windows system, how do you solve it, can you show me your code if it is convenient,This is my code ee_check_gcloud() ϵͳ�Ҳ���ָ����·���� Error in ee_check_gcloud() : gcloud failed [os.system('gcloud --help')]. Please check for any errors above and install gcloud if needed (https://cloud.google.com/sdk/docs/install).

csaybar commented 1 year ago

Hi @Phoenix11-cell Can u tell us where google-cloud-sdk is installed in your system?

ttfg22 commented 1 year ago

Hello, I have the same problem on Windows10: ee_check() (*) Python version v [Ok] E:/Programme/Anaconda/envs/rgee/python.exe v3.8 (*) Python packages: v [Ok] numpy v [Ok] earthengine-api Das System kann den angegebenen Pfad nicht finden. Error in ee_check_gcloud() : gcloud failed [os.system('gcloud --help')]. Please check for any errors above and install gcloud if needed (https://cloud.google.com/sdk/docs/install)

Google Cloud SDK is installed here: C:\Users\User name\AppData\Local\Google\Cloud SDK\google-cloud-sdk

llechler commented 1 year ago

Hello, As ttfg22 has written above, I have the same issue on Windows 10. error in py_call_impl(callable, dots$args, dots$keywords) : Exception: gcloud command not found. Please ensure that gcloud is installed. More information: https://developers.google.com/earth-engine/guides/python_install I have gcloud installed in C://, but it seems to not recognise it. Is there anything I can do similar to the solution you @csaybar provided for the Linux environment? Thanks

MehrdadVaredi commented 1 year ago

Hi @ttfg22 , @llechler I think the solution provided by @csaybar should work as well for Windows. The difference is the line where the PATH is updated with the location of gcloud. If it is added to the path, then access to gcloud will be possible,

just change: Sys.setenv(PATH=sprintf("%s:%s", Sys.getenv("PATH"), sprintf("%s/google-cloud-sdk/bin/", Sys.getenv("HOME")))) into Sys.setenv(PATH= sprintf("%s:%s", Sys.getenv("PATH"), "complete address of google-cloud-sdk on your computer"))

and use the rest of what @csaybar offered to do on https://github.com/r-spatial/rgee/issues/290#issuecomment-1272922991

I hope it helps.

MehrdadVaredi commented 1 year ago

Hi @csaybar , I used what you offered and it solved the problem.... once! I could log in and there was no problem, the second time, I got the same error. I can login using gcloud on the terminal, I can see using "gcloud auth list" that the login is completed and the account is already active and selected. But the ee_Initialize() fails. I tried logging out and using "gcloud auth revoke", but the same error showed up. when ee_check_gcloud() is run no error and no other message shows up. Is that a problem? FYI, if I run ee_check() this is what I see:

ee_check() ◉ Python version ✔ [Ok] /Users/mehrdadvaredi/.virtualenvs/rgee/bin/python v3.11 ◉ Python packages: ✔ [Ok] numpy ✔ [Ok] earthengine-api

Thanks for your help.

PetrBalej commented 1 year ago

@MehrdadVaredi, @llechler

I had same issue ( https://github.com/r-spatial/rgee/issues/290#issuecomment-1315102372 ). Solved by installing specific version (0.1.329) of earthengine-api .

pip install earthengine-api==0.1.329

Inspired by comment there: https://githublab.com/repository/activity/kvos/CoastSat

Kvos

ok thanks everybody for reporting a solution. It's a tricky problem, by forcing earthengine-api to a specific version (like 0.1.329) we may get stuck in the future as sometimes the new releeases of the API are not backwards compatible. I will just write in the documentation that if an error is raised because gcloud is not recognised, it can be fixed by downgrading to earthengine-api to 0.1.329.

Commented On 21 Nov 2022 at 01:06:12

egimenes commented 1 year ago

@MehrdadVaredi @csaybar

I tried the solution as posted by @MehrdadVaredi for Windows: just change: Sys.setenv(PATH=sprintf("%s:%s", Sys.getenv("PATH"), sprintf("%s/google-cloud-sdk/bin/", Sys.getenv("HOME")))) into Sys.setenv(PATH= sprintf("%s:%s", Sys.getenv("PATH"), "complete address of google-cloud-sdk on your computer"))

I put my path to google cloud sdk on it, but it still not working, the response for ee_check() still Error in ee_check_gcloud() : gcloud failed [os.system('gcloud --help')]. Please check for any errors above and install gcloud if needed (https://cloud.google.com/sdk/docs/install).

egimenes commented 1 year ago

@MehrdadVaredi @csaybar

I tried the solution as posted by @MehrdadVaredi for Windows: just change: Sys.setenv(PATH=sprintf("%s:%s", Sys.getenv("PATH"), sprintf("%s/google-cloud-sdk/bin/", Sys.getenv("HOME")))) into Sys.setenv(PATH= sprintf("%s:%s", Sys.getenv("PATH"), "complete address of google-cloud-sdk on your computer"))

I put my path to google cloud sdk on it, but it still not working, the response for ee_check() still Error in ee_check_gcloud() : gcloud failed [os.system('gcloud --help')]. Please check for any errors above and install gcloud if needed (https://cloud.google.com/sdk/docs/install).

I solved the problem. The googledrive package was not loading beacuse "rlang" was not updated. I removed the old version of "rlang", loaded "googledrive" and it worked.

csaybar commented 1 year ago

Hi all, sorry for the problem related to rgee ... I upgraded the README.md file.

install.packages(c("remotes", "googledrive"))
remotes::install_github("r-spatial/rgee")

library(rgee)

# Get the username
HOME <- Sys.getenv("HOME")

# 1. Install miniconda
reticulate::install_miniconda()

# 2. Install Google Cloud SDK
system("curl -sSL https://sdk.cloud.google.com | bash")

# 3 Set global parameters
Sys.setenv("RETICULATE_PYTHON" = sprintf("%s/.local/share/r-miniconda/bin/python3", HOME))
Sys.setenv("EARTHENGINE_GCLOUD" = sprintf("%s/google-cloud-sdk/bin/", HOME))

# 4 Install rgee Python dependencies
ee_install()

# 5. Authenticate and init your EE session
ee_Initialize()

If you are trying to use rgee in a Docker container or a server. Take a look at https://posit.cloud/content/5175749

llechler commented 1 year ago

Hi @csaybar , I tried following your instructions but I got the same error message again regarding Google Cloud:

✔ Initializing Google Earth Engine:Fetching credentials using gcloud
Error in py_call_impl(callable, dots$args, dots$keywords) : 
  Exception: gcloud command not found. Please ensure that gcloud is installed.
More information: https://developers.google.com/earth-engine/guides/python_install

I think the error must be from this line of your code: # 2. Install Google Cloud SDK system("curl -sSL https://sdk.cloud.google.com | bash")

because when I run it in R, I get this error message:

!/bin/bash

URL=https://dl.google.com/dl/cloudsdk/channels/rapid/install_google_cloud_sdk.bash

function download { scratch="$(mktemp -d -t tmp.XXXXXXXXXX)" || exit script_file="$scratch/install_google_cloud_sdk.bash"

echo "Downloading Google Cloud SDK install script: $URL" curl -# "$URL" > "$script_file" || exit chmod 775 "$script_file"

echo "Running install script from: $script_file" "$script_file" "$@" }

download "$@" curl: (6) Could not resolve host: | curl: (6) Could not resolve host: bash [1] 6

Do you happen to have any idea how I could resolve this? Thanks a lot, Lia

csaybar commented 1 year ago

Hi @llechler does it happen on your computer or Rstudio (Posit) computer?

llechler commented 1 year ago

Hi @csaybar,

It happens on this version of the R Studio Desktop App R Studio 2022.12.0+353 "Elsbeth Geranium" Release (7d165dcfc1b6d300eb247738db2c7076234f6ef0, 2022-12-03) for Windows Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2022.12.0+353 Chrome/102.0.5005.167 Electron/19.1.3 Safari/537.36

I also followed your trouble shooting tutorial https://r-spatial.github.io/rgee/articles/rgee05.html, but the issue is that as soon as I try to copy the generate SaK in my system, the error mentioned above (Error in py_call_impl(callable, dots$args, dots$keywords) : Exception: gcloud command not found. Please ensure that gcloud is installed.) when trying to run ee_Initialize() is preventing me from completing the tutorial.

Thanks, Lia

csaybar commented 1 year ago

The SaK is the service account key. It's used to authenticate google cloud services, such as Google Cloud Storage. In your case, your system doesn't know where exactly is stored gcloud CLI. gcloud CLI is used for EE to authenticate new users in a fresh computer (it's a new security layer recently implemented).

✔ Initializing Google Earth Engine:Fetching credentials using gcloud
Error in py_call_impl(callable, dots$args, dots$keywords) : 
  Exception: gcloud command not found. Please ensure that gcloud is installed.
More information: https://developers.google.com/earth-engine/guides/python_install

I'm not a Windows user, but this line only will work in Unix systems (IDK, maybe new Windows versions, yes).

system("curl -sSL https://sdk.cloud.google.com | bash")

So in Windows, you will have to install gcloud CLI on your own the error message show you were to find the installer:

Exception: gcloud command not found. Please ensure that gcloud is installed.
More information: https://developers.google.com/earth-engine/guides/python_install

Then, you will have to set the location of the folder in the PATH ENV (i think Windows do this automatically for you). If not, you will have to do it on your own. You can also define from within R the variable EARTHENGINE_GCLOUD. It's the same that setting the folder in the PATH ENV.

Sys.setenv("EARTHENGINE_GCLOUD" = "PUT HERE THE PATH"

This issue should affect Python users as well. Consider that

# reticulate requirement
Sys.setenv("RETICULATE_PYTHON" = sprintf("%s/.local/share/r-miniconda/bin/python3", HOME)) 
# earth engine requirement
Sys.setenv("EARTHENGINE_GCLOUD" = sprintf("%s/google-cloud-sdk/bin/", HOME))
llechler commented 1 year ago

Hi @csaybar,

I followed your instructions exactly as you specified above, including downloading Google Cloud CLI and specifying the path environment as you instructed. Unfortunately I still get the same error message as before Error in py_call_impl(callable, dots$args, dots$keywords) : Exception: gcloud command not found. Please ensure that gcloud is installed. Is there anything else I could try? Thanks

csaybar commented 1 year ago

hi @llechler, does it work?

library(rgee)
ee_Authenticate(auth_mode='notebook')
ee_Initialize()
edarin commented 1 year ago

Hi everyone, Nice to see other people struggling with the same issue (probably!).

I keep having this issue > ee_check_gcloud() The system cannot find the path specified. Error in ee_check_gcloud() : gcloud failed [os.system('gcloud --help')]. Please check for any errors above and install gcloud if needed (https://cloud.google.com/sdk/docs/install).

altough:

  1. I have downloaded manually gcloud and added to my path
  2. If I open a terminal, gcloud --h gives back the help
  3. And even weirder, I have run from the ee_check_gcloud function, this bit os$system("gcloud --help ") and it does return 0 (and the entire help) but not os$system("gcloud --help > /dev/null 2>&1") that returns The system cannot find the path specified.

Lastly ee_Authenticate(auth_mode='notebook') unfortunately fails with the same gcloud-related error message.

I am a Windows 10 users (nobody's perfect!).

And thanks @csaybar for the diligent support. I have been using rgee in the past (eg 6 months ago) and it was smoooth. (And i just tried as it was installed on another machine and still works nicely: rgee 1.1.4, earthengine-api 0.1.317).

csaybar commented 1 year ago

@edarin, does it work?

library(rgee)
ee_Authenticate(auth_mode='notebook')
ee_Initialize()
edarin commented 1 year ago

Ey! So as I said previously, it didnt work unfortunately.

I did more digging:

I have directly try to run ee.Authenticate from the python of the rgee environment. For the Windows users, paste the path given by Sys.getenv('EARTHENGINE_PYTHON') in your File Explorer.

import ee
ee.Authenticate

And I got a similar output as described here. I followed their recommendation by downgrading the earthengine-api: reticulate::py_install('earthengine-api==0.1.329', envname='rgee').

And ee_Initialize worked!

I have then updated 'earthengine-api' back to the latest version available.

And ee_Initialize still worked!

Note that ee_check_gcloud() still think that it's not working (as said previously os$system("gcloud --help") is accurate for me but not the current check os$system("gcloud --help > /dev/null 2>&1"))

csaybar commented 1 year ago

I think this problem has been solved in rgee 1.1.6. Please feel free to open a new issue if you still need help. ee_Initialize and ee_Authenticate now use auth_mode="notebook" by default.

Technew94 commented 1 year ago

Hi there,

I'm working on ubuntu 22.04, trying to install rgee, when I initialize, there's an error, Credentials neccesaries for rgee: Error in ee_check_credentials(): Does not exist earth engine credentials in their system. Try rgee::ee_Initialize() to fixed. But when I try this error again: [Error in py_call_impl(callable, dots$args, dots$keywords]: Exception: gcloud failed. Please check for any errors above and install gcloud if needed. Do someone knows how to fix this? btw, rgee works well on my office windows PC.

Thanks in advance!

AlvaroMCMC commented 1 year ago

Hi. I tried all of this, but the error remains.

Error in py_call_impl(callable, dots$args, dots$keywords) :
Exception: gcloud command not found. Please ensure that gcloud is installed.
More information: https://developers.google.com/earth-engine/guides/python_install
RonaldoAG commented 2 weeks ago

Error in task$start() using ee_table_to_drive

Error in py_call_impl(callable, call_args$unnamed, call_args$named) : ee.ee_exception.EEException: Request had insufficient authentication scopes. Run reticulate::py_last_error() for details.