0

I'm trying to use the App Engine Remote API in Google Cloud Shell, but keep getting the error "ImportError: No module named appengine.tools".

First, I've followed these steps to set my Cloud Shell to a clean state.

Then, I attempt to start the API shell with the following command:

/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/remote_api_shell.py -s [myprojectID].appspot.com

First, I get the error "-bash: /google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/remote_api_shell.py: Permission denied" so I navigate to the file and do

sudo chmod +x remote_api_shell.py

Then, when I attempt the command again, I get the ImportError above.

I've looked at a few similar threads (here) and (here) and users seem to report that doing "sudo pip uninstall protobuf" fixed their issue, but that isn't doing the trick for me.

Another suggestion was adding the App Engine SDK to the PYTHONPATH, so I've tried executing

 export PYTHONPATH=/usr/bin/python2.7
 export GAE_SDK_ROOT="/google/google-cloud-sdk/platform/google_appengine/"
 export PYTHONPATH=${GAE_SDK_ROOT}:${PYTHONPATH}

But the error persists. I think the issue is reflected here:

>>> import google
>>> print google.__path__
['/usr/local/lib/python2.7/dist-packages/google']

Is there a way to quickly fix this while preserving as much of the default state of the Cloud Shell as possible? Since the Cloud Shell is ephemeral, I suppose the process will need to be repeated.

I have configured my application to enable remote access, though I don't believe I've gotten far enough for that to be the issue.

All Gcloud components are up to date, as I suppose is guaranteed when I clean the Cloud Shell state.

Prepending "python" or "python2" to the command results in the same error.

Edited to add the full error message:

Traceback (most recent call last):
File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/remote_api_shell.py", line 29, in <module>
from google.appengine.tools import os_compat
ImportError: No module named appengine.tools
  • Try `python /google/google-cloud-sdk/platform/google_appengine/remote_api_shell.py ...` – Dan Cornilescu Aug 03 '18 at 17:50
  • Edited to add that prepending "python" or "python2" results in the same error. If I try that exact command, I get "ValueError: GAE_SDK_ROOT '/google/google-cloud-sdk/platform/google_appengine/google' does not refer to a valid SDK directory" – Jables Hables Aug 03 '18 at 17:55
  • Note the different `remote_api_shell.py` path, one dir higher... – Dan Cornilescu Aug 03 '18 at 17:57
  • Alright, it looks like that worked after I cleaned the shell state again, since it appears the GAE_SDK_ROOT settings above prevented it from executing. I'm not entirely sure how I missed this other instance of that file -- any idea why there are two of them? – Jables Hables Aug 03 '18 at 18:53

1 Answers1

1

As suggested by Dan Cornilescu, the root cause of the issue appears to be that I was executing the wrong file. After cleaning the Cloud Shell state once more, I executed:

python /google/google-cloud-sdk/platform/google_appengine/remote_api_shell.py -s [myprojectID].appspot.com

and it worked