【问题标题】:Google App Engine Python Remote API in Cloud Shell: No module named appengine.toolsCloud Shell 中的 Google App Engine Python Remote API:没有名为 appengine.tools 的模块
【发布时间】:2018-08-03 17:36:58
【问题描述】:

我正在尝试在Google Cloud Shell 中使用App Engine Remote API,但不断收到错误“ImportError: No module named appengine.tools”。

首先,我已按照 these steps 将我的 Cloud Shell 设置为干净状态。

然后,我尝试使用以下命令启动 API shell:

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

首先,我收到错误“-bash: /google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/remote_api_shell.py: Permission denied”所以我导航到文件并做

sudo chmod +x remote_api_shell.py

然后,当我再次尝试该命令时,我得到了上面的 ImportError。

我查看了一些类似的线程 (here) 和 (here),用户似乎报告说执行“sudo pip uninstall protobuf”解决了他们的问题,但这对我来说并没有解决问题.

另一个建议是将 App Engine SDK 添加到 PYTHONPATH,所以我尝试执行

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

但错误仍然存​​在。我认为问题反映在这里:

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

有没有办法快速解决这个问题,同时尽可能多地保留 Cloud Shell 的默认状态?由于 Cloud Shell 是短暂的,我想这个过程需要重复。

我已将我的应用程序配置为启用远程访问,但我不认为我已经做到了足以解决这个问题。

所有 Gcloud 组件都是最新的,我想在我清理 Cloud Shell 状态时可以保证。

在命令前添加“python”或“python2”会导致同样的错误。

已编辑以添加完整的错误消息:

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

【问题讨论】:

  • 试试python /google/google-cloud-sdk/platform/google_appengine/remote_api_shell.py ...
  • 编辑添加前置“python”或“python2”会导致相同的错误。如果我尝试那个确切的命令,我会得到“ValueError: GAE_SDK_ROOT '/google/google-cloud-sdk/platform/google_appengine/google' 没有引用有效的 SDK 目录”
  • 注意不同的remote_api_shell.py 路径,高一级...
  • 好吧,在我再次清理 shell 状态后,它看起来有效,因为上面的 GAE_SDK_ROOT 设置似乎阻止了它执行。我不完全确定我是如何错过该文件的另一个实例的——知道为什么会有两个吗?

标签: google-app-engine google-app-engine-python google-cloud-shell


【解决方案1】:

正如Dan Cornilescu 所建议的,问题的根本原因似乎是我执行了错误的文件。再次清理 Cloud Shell 状态后,我执行了:

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

成功了

【讨论】:

    猜你喜欢
    • 2013-12-06
    • 1970-01-01
    • 2015-04-24
    • 2018-08-05
    • 1970-01-01
    • 2019-02-26
    • 2019-01-30
    • 2021-07-05
    • 2015-01-25
    相关资源
    最近更新 更多