首页 > 解决方案 > Django 无法通过 mod_wsgi 错误部署 [AWS]

问题描述

尝试通过 Elastic Beanstalk 服务部署我的 django 应用程序时遇到错误。本地一切正常。

我还尝试根据答案修改我的代码Django stop working with RuntimeError: populate() is not reentrant and this Target WSGI script '/opt/python/current/app/ ... /wsgi.py' cannot be loaded as Python module 没有成功。

 [:error] [pid 3519] mod_wsgi (pid=3519): Target WSGI script '/opt/python/current/app/diamond/wsgi.py' cannot be loaded as Python module.
 [:error] [pid 3519] mod_wsgi (pid=3519): Exception occurred processing WSGI script '/opt/python/current/app/diamond/wsgi.py'.
 [:error] [pid 3519] Traceback (most recent call last):
 [:error] [pid 3519]   File "/opt/python/current/app/diamond/wsgi.py", line 16, in <module>
 [:error] [pid 3519]     application = get_wsgi_application()
 [:error] [pid 3519]   File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
 [:error] [pid 3519]     django.setup(set_prefix=False)
 [:error] [pid 3519]   File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/__init__.py", line 24, in setup
 [:error] [pid 3519]    apps.populate(settings.INSTALLED_APPS)
 [:error] [pid 3519]   File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/apps/registry.py", line 81, in populate
 [:error] [pid 3519]     raise RuntimeError("populate() isn't reentrant")
 [:error] [pid 3519] RuntimeError: populate() isn't reentrant

此外,我的 wsgi.py 文件:

import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "diamond.settings")

application = get_wsgi_application()

和我的django.config加入

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: diamond/wsgi.py

提前致谢

标签: pythondjangoamazon-web-servicesmod-wsgiamazon-elastic-beanstalk

解决方案


推荐阅读