如何在Google App Engine的本地开发服务器上使用Python 3

如何在Google App Engine的本地开发服务器上使用Python 3

问题描述:

我已经配置了一个本地Python应用程序

I've got a local Python application configured with

runtime: python

在它的app.yaml文件中.使用

dev_appserver.py app.yaml

一切都很好.

由于GAE的本地开发服务器默认使用Python2.7,因此我现在想使用Python3.x.根据Google的文档,我们必须使用灵活的环境.因此,我将app.yaml更改为:

Since GAE's Local Development Server uses Python2.7 by default, I now want to make use of Python3.x instead. According to Google's documentation, we have to use the flexible environment. Thus I'm changing app.yaml to:

runtime: python
env: flex

runtime_config:
  python_version: 3

现在dev_appserver.py app.yaml退出:

Under dev_appserver, runtime:python is not supported for Flexible environment.

可以使用 Google的Hello World应用程序重现该问题也使用灵活的环境.

The problem can be reproduced with Google's Hello World application that uses the flexible environment as well.

所以在本地我们不能使用Python3?在上传之前,我们如何在本地运行我的Python3代码?

So locally we can't use Python3? How can we then run my Python3 code locally before uploading it?

Using the Local Development Server is applicable to the first generation standard environment apps only.

有关运行本地灵活的env应用程序的信息,请参见

For running locally flexible env apps see Running locally:

您可以使用本机开发工具在本地运行应用程序 您通常使用的.

You run your application locally with the native development tools that you usually use.

例如,您通常可以使用Flask的 开发服务器使用:

For example, you can usually run a Flask application with Flask's development server using:

python main.py

可以使用以下命令启动Django应用程序:

Django applications can be started using:

python manage.py runserver

相关: 更新:

对第二代标准环境的支持是有限的,请参见

Support for the 2nd generation standard environment is limited, see Python 3.7 Local Development Server Options for new app engine apps