Flask导入在Google App Engine的标准环境中失败

时间:2017-09-24 08:47:14

标签: python google-app-engine

我已经指定了app.yaml文件,如下所示:

runtime: python
env: standard
# this assumes that the entrypoint is app.py
entrypoint: gunicorn -b :$PORT main:app
threadsafe: true

运行gcloud app deploy后,我面临500错误,日志显示以下内容

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
  File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
  File "/base/data/home/apps/g~test-website/20170924t080410.404328292497306090/app.py", line 3, in <module>
from flask import Flask, render_template
ImportError: No module named flask

任何人都可以帮我配置标准环境

1 个答案:

答案 0 :(得分:1)

您正在为app.yaml

中的灵活环境和标准环境组合语法

查看documentation for the app.yaml并坚持使用标准环境参考。 env参数仅用于flex,而entrypoint仅用于flex。 runtime参数应为python27,因为python表示已弃用的Python 2.5运行时。

鉴于您尝试使用Flask,您应该阅读getting started guide that is specifically for Flask