django - 在 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
解决方案
这是因为 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。
推荐阅读
- rust - 在substrate中声明一个hashmap(storageMap)
- python - 导入“statsmodels.api”包时,Django API 不断加载并引发超时错误
- node.js - 如何在快速验证中添加 if 条件 6
- vue.js - 在 vue 3 中使用 vite 引用数据属性或方法中的资产
- javascript - 如何相对于其父级的父级移动元素
- sql - 如何识别在使用 JSON 和 Node JS 插入多条记录时出现错误的记录
- python - 如何用python检测正确的文件编码?
- angular - 来自另一个组件的Angular 9调用函数
- python - 如何对元素为 dict 对象的列表进行排序?
- swift - SwiftUI 显示和关闭文本字段键盘