0

I create a GCP instance with a prebuilt image (c3-deeplearning-tf-ent-1-15-cu100-20200313). I remotely executed "script.py" using the following command.

$ gcloud compute ssh me_as_user@instance -- 'python script.py'

and I got tensorflow import error, but there is the package under me_as_user, and there is no issue executing "script.py" in SSH.

Please advise me if there there is any suggestion. Thank you

Troy
  • 95
  • 1
  • 4
  • 1
    Is `script.py` on the remote instance? You must copy it there (e.g. `gcloud compute scp ...``) before you can run it there. – DazWilkin Mar 30 '20 at 16:41
  • Yes. when I execute 'script.py' on SSH, I had no issue, but I had issue only when I execute the file like as the question – Troy Mar 30 '20 at 16:55
  • 1
    Hmmm.... are you using `gcloud compute ssh ..... --command `python script.py"`? – DazWilkin Mar 30 '20 at 17:01
  • Yes. that's what I am trying to. I guess `--command 'python script.py` and `-- 'python script.py'` are same. I tried both and did not work – Troy Mar 30 '20 at 19:12
  • 1
    Here's an example using Cloud Shell: `gcloud alpha cloud-shell ssh --command="echo \"print('Hello Freddie')\" > script.py && python3 script.py"`. This works for me, returning `Hello Freddie` – DazWilkin Mar 30 '20 at 20:05
  • 1
    You could also ensure your `script.py` file is present and that `python` is available by: `--command="which python; ls -l script.py"`. Otherwise, I'm outta ideas. – DazWilkin Mar 30 '20 at 20:10
  • Does this answer your question? [gcloud compute execute command remotely](https://stackoverflow.com/questions/39098341/gcloud-compute-execute-command-remotely) – sllopis Mar 31 '20 at 13:50

0 Answers0