如何将 Python 3 与 Google App Engine 的本地开发服务器一起使用
How to use Python 3 with Google App Engine's Local Development Server
我有一个配置了
的本地 Python 应用程序
runtime: python
在它的 app.yaml
文件中。使用
启动本地开发服务器时
dev_appserver.py app.yaml
一切都很好。
由于 GAE 的本地开发服务器默认使用 Python2.7,我现在想改用 Python3.x。根据Google的文档,我们必须使用flexible environment。因此,我将 app.yaml
更改为:
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's Hello World application 重现。
所以我们不能在本地使用 Python3?那么我们如何才能 运行 我的 Python3 在上传之前在本地编码?
Using the Local Development Server仅适用于第一代标准环境应用。
对于 运行 本地灵活的环境应用,请参阅 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
相关:
更新:
对第二代标准环境的支持有限,参见
添加更新的答案(2022 年)
Google App Engine 支持 运行ning Python 3 个使用 dev_appserver.py
的应用程序(但不适用于 Windows)
Per their documentation, ....To 运行 dev_appserver with a Python 3 interpreter, you must指定 --runtime_python_path=[PATH_TO_PYTHON3_BINARY] flag
.....
一些捆绑服务(内置 API),如用户、内存缓存、数据存储、命名空间管理器现在也是 available for Python3 应用程序。当您启用它们并使用 dev_appserver.py
到 运行 您的 Python3 应用程序时,您将获得与在 Python2 中习惯的相同行为,即您将获得一个模拟数据存储、内存缓存、用户等
我有一个配置了
的本地 Python 应用程序runtime: python
在它的 app.yaml
文件中。使用
dev_appserver.py app.yaml
一切都很好。
由于 GAE 的本地开发服务器默认使用 Python2.7,我现在想改用 Python3.x。根据Google的文档,我们必须使用flexible environment。因此,我将 app.yaml
更改为:
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's Hello World application 重现。
所以我们不能在本地使用 Python3?那么我们如何才能 运行 我的 Python3 在上传之前在本地编码?
Using the Local Development Server仅适用于第一代标准环境应用。
对于 运行 本地灵活的环境应用,请参阅 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
相关:
更新:
对第二代标准环境的支持有限,参见
添加更新的答案(2022 年)
Google App Engine 支持 运行ning Python 3 个使用
dev_appserver.py
的应用程序(但不适用于 Windows)Per their documentation, ....To 运行 dev_appserver with a Python 3 interpreter, you must指定
--runtime_python_path=[PATH_TO_PYTHON3_BINARY] flag
.....一些捆绑服务(内置 API),如用户、内存缓存、数据存储、命名空间管理器现在也是 available for Python3 应用程序。当您启用它们并使用
dev_appserver.py
到 运行 您的 Python3 应用程序时,您将获得与在 Python2 中习惯的相同行为,即您将获得一个模拟数据存储、内存缓存、用户等