gpt4 book ai didi

python-3.x - 新应用引擎应用的 Python 3.7 本地开发服务器选项

转载 作者:太空宇宙 更新时间:2023-11-03 15:20:53 24 4
gpt4 key购买 nike

我有一个在标准 Python3 运行时上部署和运行的应用引擎应用程序。我还可以使用 flask run 等普通命令在本地运行它。但是我无法像使用 dev_appserver.py 在 2.7 运行时中运行应用程序那样运行它。我使用的是最新的 gcloud 版本,但运行 dev_appserver.py 结果是:

ERROR: Python 3 and later is not compatible with the Google Cloud SDK. Please use Python version 2.7.x.

我以为我们不应该再这样做了,直到它看到: https://cloud.google.com/appengine/docs/standard/python3/tools/local-devserver-command

开头是:

Python 3.7 Local Development Server Options

Usage:
dev_appserver.py [options] yaml_path [files...]

dev_appserver.py 是否与 Python3 兼容(也许我的路径中有一个旧版本)?如果没有,是否有一种在本地运行应用程序的新方法将遵守 app.yaml(如正确处理静态路径)并提供其他细节,如 dev_appserver.py 提供的本地数据存储?

最佳答案

dev_appserver.py 对 Python 3 的支持仍然有限。来自 Running the local development server :

Note:

  • Running dev_appserver requires the presence of Python 2.7.12+ on your local machine.
  • The updated dev_appserver does not support development of Python 3 apps on Windows.

可能就是为什么它不是本地开发的推荐解决方案(或者至少现在还不是)。来自 Running locally :

We do not recommend that you depend on tools like dev_appserver, the local development server provided with the Google Cloud SDK. However, if you are migrating an existing App Engine application from Python 2 to Python 3, we have updated dev_appserver to facilitate this process. For all other local development scenarios, we recommend standard Python testing approaches.

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

To simulate a production App Engine environment, you can run the full Web Server Gateway Interface (WSGI) server locally. To do this, use the same command specified as entrypoint in your app.yaml, for example:

gunicorn -b :$PORT main:app

关于python-3.x - 新应用引擎应用的 Python 3.7 本地开发服务器选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52999747/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com