gpt4 book ai didi

App Engine 标准 : App Fails to Start 上的 Python 3 Django

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

我正在尝试在标准 Python37 环境中的 Google App Engine 上部署 Django 应用程序。我有一个在灵活环境中运行良好的版本,但我正在创建一个我想在标准环境中运行的暂存版本。

当我部署和访问该应用程序时,出现 500 错误。查看日志,我可以看到一些关于工作进程异常的消息。我收到错误:

ModuleNotFoundError: No module named 'main'

这是错误的堆栈跟踪:

Traceback (most recent call last):

File "/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process()

File "/env/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 104, in init_process super(ThreadWorker, self).init_process()

File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process self.load_wsgi()

File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi self.wsgi = self.app.wsgi()

File "/env/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load()

File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load return self.load_wsgiapp()

File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp return util.import_app(self.app_uri)

File "/env/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app import(module)

ModuleNotFoundError: No module named 'main'

自从 Django 为我创建 my_site/wsgi.py 以来,我还没有修改它,这里是:

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_site.settings")

application = get_wsgi_application()

这是我的app.yaml:

runtime: python37
env: standard

beta_settings:
cloud_sql_instances: project:us-west1:sql-instance

handlers:
- url: /static
static_dir: staticfiles/
- url: .*
secure: always
redirect_http_response_code: 301
script: my_site.wsgi.application

env_variables:
# vars

这与 app.yaml 非常接近:https://cloud.google.com/python/django/appengine .我还尝试将 script 更改为 auto,如下所示:https://cloud.google.com/appengine/docs/standard/python3/config/appref , 但仍然出现相同的错误。

我看过这个问题:Django - gunicorn on App Engine. Error: 'No Module Named my_project' , my_site 确实有下划线,但不是驼峰式。

我不确定这个错误的来源是什么。任何想法将不胜感激。

最佳答案

您可能需要将 entrypoint 添加到您的 app.yaml

runtime: python37
entrypoint: gunicorn -b :8080 my_site.wsgi

...(remaining parts of your app.yaml)

引用: https://cloud.google.com/appengine/docs/standard/python3/runtime

关于App Engine 标准 : App Fails to Start 上的 Python 3 Django,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52416588/

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