rgee icon indicating copy to clipboard operation
rgee copied to clipboard

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

Open POTCHARAARIYA opened this issue 3 years ago • 13 comments

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?

POTCHARAARIYA avatar Sep 17 '22 10:09 POTCHARAARIYA

I encountered the same problem

LucasXin1 avatar Oct 08 '22 10:10 LucasXin1

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

csaybar avatar Oct 08 '22 11:10 csaybar

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: @.***>

LucasXin1 avatar Oct 08 '22 17:10 LucasXin1

@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).

POTCHARAARIYA avatar Oct 10 '22 04:10 POTCHARAARIYA

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.

csaybar avatar Oct 10 '22 04:10 csaybar

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: @.***>

LucasXin1 avatar Oct 10 '22 04:10 LucasXin1

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.

POTCHARAARIYA avatar Oct 10 '22 07:10 POTCHARAARIYA

can u run?

system("gcloud --help")

csaybar avatar Oct 10 '22 07:10 csaybar

system("gcloud --help")

On Terminal or R studio?

POTCHARAARIYA avatar Oct 10 '22 07:10 POTCHARAARIYA

In your R ENV.

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

csaybar avatar Oct 10 '22 07:10 csaybar

In your R ENV.

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

T_T

POTCHARAARIYA avatar Oct 10 '22 07:10 POTCHARAARIYA

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()

csaybar avatar Oct 10 '22 07:10 csaybar

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!!!

POTCHARAARIYA avatar Oct 10 '22 08:10 POTCHARAARIYA

@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).

Phoenix11-cell avatar Oct 24 '22 13:10 Phoenix11-cell

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

csaybar avatar Oct 24 '22 13:10 csaybar

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

ttfg22 avatar Oct 26 '22 09:10 ttfg22

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

llechler avatar Nov 15 '22 10:11 llechler

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 avatar Dec 04 '22 18:12 MehrdadVaredi

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.

MehrdadVaredi avatar Dec 04 '22 20:12 MehrdadVaredi

@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

PetrBalej avatar Dec 04 '22 23:12 PetrBalej

@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 avatar Dec 28 '22 21:12 egimenes

@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.

egimenes avatar Dec 29 '22 12:12 egimenes

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

csaybar avatar Dec 30 '22 21:12 csaybar

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

llechler avatar Jan 10 '23 14:01 llechler

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

csaybar avatar Jan 10 '23 15:01 csaybar

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

llechler avatar Jan 10 '23 15:01 llechler

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))

csaybar avatar Jan 10 '23 15:01 csaybar

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

llechler avatar Jan 10 '23 17:01 llechler

hi @llechler, does it work?

library(rgee)
ee_Authenticate(auth_mode='notebook')
ee_Initialize()

csaybar avatar Jan 11 '23 13:01 csaybar

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).

edarin avatar Jan 13 '23 19:01 edarin