【问题标题】:"No module named cloud" while deploying to Google App Engine部署到 Google App Engine 时出现“没有名为 cloud 的模块”
【发布时间】:2019-01-30 02:02:40
【问题描述】:

我为 Google App Engine 构建了一个应用程序,当我尝试运行该应用程序时,它运行良好。但是当我部署它时,它抛出了内部服务器 500 错误。当我检查错误报告时,它说“目录中没有名为cloud的模块”

下面是我的 requirements.txt

gunicorn==19.3.0
twilio==6.8.4
google-cloud-automl==0.1.1
google-cloud-storage==1.0.0
google-cloud==0.34.0
GoogleAppEngineCloudStorageClient==1.9.22.1

我的Yaml文件如下

runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: .*
  script: main.app

python文件中使用的导入是

from google.cloud import automl_v1beta1 as automl
from google.cloud import storage

当我手动运行时它起作用了。但部署后,错误是

ImportError: No module named cloud
<module> (/base/data/home/apps/..

提前谢谢你

【问题讨论】:

    标签: python google-app-engine google-cloud-platform google-cloud-storage pypi


    【解决方案1】:

    首先,the google-cloud package has been deprecated

    其次,您不能在 App Engine Standard 中使用 google-cloud-* 库。您必须使用其他替代方法,例如 GoogleAppEngineCloudStorageClient

    【讨论】:

    • 由于我使用的是 AutoML 的东西,我认为应用引擎没有用于 AutoML 的独立包。此外,GoogleAppEngineCloudStorage 也在我的 requirements.txt 中。
    【解决方案2】:

    您似乎正在尝试部署到“第一代”App Engine 运行时。不幸的是,你不能在那里使用google-cloud Python 库。

    好消息是您可以改用“第二代”,它允许您安装任何库,包括任何 google-cloud 库,例如 google-cloud-storage

    两代的区别见此链接:https://cloud.google.com/appengine/docs/standard/appengine-generation

    Google App Engine Python 3 标准环境文档:https://cloud.google.com/appengine/docs/standard/python3/

    【讨论】:

    • 所以你的意思是说,只需要更改反映第二代的yaml文件才能部署?
    【解决方案3】:

    请执行pip install google-cloud-automl

    这将解决问题。

    【讨论】:

      猜你喜欢
      • 2020-01-18
      • 2020-01-22
      • 2019-01-13
      • 1970-01-01
      • 2015-04-24
      • 2018-08-05
      • 1970-01-01
      • 1970-01-01
      • 2021-07-05
      相关资源
      最近更新 更多