How to use Python 3 with Google App Engine's Local Development Server

落爺英雄遲暮 提交于 2019-12-01 01:14:09

问题


I've got a local Python application configured with

runtime: python

in it's app.yaml file. When starting the local development server with

dev_appserver.py app.yaml

all is fine.

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

Now dev_appserver.py app.yaml spits out:

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

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

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


回答1:


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

For running locally flexible env apps see Running locally:

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

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

python main.py

Django applications can be started using:

python manage.py runserver

Related: How to tell if a Google App Engine documentation page applies to the standard or the flexible environment

Update:

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



来源:https://stackoverflow.com/questions/46432589/how-to-use-python-3-with-google-app-engines-local-development-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!