python - 无法在 python shell 中导入 GAE api

标签 python google-app-engine

我已经下载了 GAE SDK 并想从 python shell 使用它的 api。

我在我的 .bashrc 中放置了以下内容,其中 google_appengine 是我解压缩 SDK 的文件夹 -

#GAE
export PATH=$PATH:/opt/google_appengine/

现在我已经使用 virtualenv 创建了一个新项目。当我启动 python shell 并尝试使用它的 api 时,出现以下错误 -

>>> from google.appengine.ext import db
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named google.appengine.ext

有人可以帮我调试吗?

最佳答案

仅仅通过这样做,您就缺少了很多设置。你会找到 使用远程 api 外壳要容易得多。只需运行 python $PATH_TO_APPENGINE/remote_api_shell.py appid,这将为您提供一个正确定义了所有路径的 shell。您实际上不必连接到远程实例,尽管这很有用。在没有某些数据存储后端的情况下,您无法真正通过 shell 使用任何模型。您还可以使用远程 api shell 连接到本地开发服务器实例。

在此处查看有关使用它的好文章 https://developers.google.com/appengine/articles/remote_api

关于python - 无法在 python shell 中导入 GAE api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11609892/

相关文章:

google-app-engine - 是否可以在运行时读取 Google App Engine 应用程序的版本?

python - 在 Pandas 数据框替换功能中使用正则表达式匹配组

python - 如何扩展现有的 python 实例

python - 错误,“[错误] 33#33 : *92500 connect() failed (111: Connection refused) while connecting to upstream, 客户端 : 216. 58.212.244,服务器:#1906

python - 完整的原型(prototype)太大而无法保存,已清除变量

python - App Engine + Django : ImportError: No module named django. core.wsgi

google-app-engine - GAE 数据存储备份

python - python中的分割方法错误

python - Pandas 数据帧 : how can i compare values in two columns of a row are equal to the ones in the same columns of a subsequent row?

python - 错误处理所需的输入