[英]Django 'ModuleNotFoundError: No module named 'blog/wsgi' when deploying to Elastic Beanstalk, as well as 'Error while connecting to Upstream'
I am trying to deploy a static Django website to Elastic Beanstalk via the UI 'upload your code' and not the EB CLI.我正在尝试通过 UI“上传您的代码”而不是 EB CLI 将 static Django 网站部署到 Elastic Beanstalk。 I have created a zip file of all of my contents and have tried uploading it a million times, only to be met with the errors 'ModuleNotFoundError: No module named 'blog/wsgi' when deploying to Elastic Beanstalk, as well as 'Error while connecting to Upstream'.
我已经为我的所有内容创建了一个 zip 文件,并尝试将其上传一百万次,结果却遇到错误“ModuleNotFoundError:部署到 Elastic Beanstalk 时没有名为‘blog/wsgi’的模块”,以及“同时出错”连接到上游”。 I think it is an error with the 'django.config' file in my.ebextensions folder.
我认为这是 my.ebextensions 文件夹中的“django.config”文件的错误。 The contents of the 'django.config' file is:
option_settings: aws:elasticbeanstalk:container:python: WSGIPath: blog/wsgi:application
. “django.config”文件的内容是:
option_settings: aws:elasticbeanstalk:container:python: WSGIPath: blog/wsgi:application
。 The contents of my 'wsgi.py' file is import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'blog.blog.settings') application = get_wsgi_application()
.我的“wsgi.py”文件的内容是
import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'blog.blog.settings') application = get_wsgi_application()
。 I have attached a screenshot of my folder structure as well.我还附上了我的文件夹结构的屏幕截图。 I can attach any other files if necessary.
如有必要,我可以附上任何其他文件。 Thank you.
谢谢你。
I faced the same issue when deploying to Amazon Linux 2 machine due to incompatibility of versions.由于版本不兼容,我在部署到 Amazon Linux 2 机器时遇到了同样的问题。 I fixed it by changing the django.config file:
我通过更改 django.config 文件修复了它:
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: ebdjango.wsgi
Credits to this answer归功于这个答案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.