首页 > 解决方案 > 在 Elastic Beanstalk 上使用 Django 2.2 时出现 WSGI 错误

问题描述

尝试访问部署到 AWS Elastic Beanstalk 的 Django 2.2 Web 应用程序会出现 500 错误。检查弹性豆茎日志时,会显示以下错误。

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

标签: djangomod-wsgiamazon-elastic-beanstalk

解决方案


这是因为 Django 2.2(在撰写本文时)与 EB 不兼容。

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html

Django 2.2 与 Elastic Beanstalk Python 3.6 平台不兼容。最新的兼容版本是 Django 2.1。


推荐阅读