[英]ImportError: No module named django.core.wsgi in Elastic Beanstalk
I was getting started with AWS' Elastic Beanstalk . 我开始使用AWS的Elastic Beanstalk 。
I am following this tutorial to deploy a Django/PostgreSQL app . 我按照本教程来部署Django / PostgreSQL应用程序 。
I did everything before the 'Configuring a Database' section. 我在“配置数据库”部分之前做了所有事情。 The deployment was also successful but I am getting an Internal Server Error.
部署也很成功,但我收到内部服务器错误。
Here's the traceback from the logs: 这是日志中的追溯:
mod_wsgi (pid=30226): Target WSGI script '/opt/python/current/app/polly/wsgi.py' cannot be loaded as Python module.
[Tue Sep 15 12:06:43.472954 2015] [:error] [pid 30226] [remote 172.31.14.126:53947] mod_wsgi (pid=30226): Exception occurred processing WSGI script '/opt/python/current/app/polly/wsgi.py'.
[Tue Sep 15 12:06:43.474702 2015] [:error] [pid 30226] [remote 172.31.14.126:53947] Traceback (most recent call last):
[Tue Sep 15 12:06:43.474727 2015] [:error] [pid 30226] [remote 172.31.14.126:53947] File "/opt/python/current/app/polly/wsgi.py", line 12, in <module>
[Tue Sep 15 12:06:43.474777 2015] [:error] [pid 30226] [remote 172.31.14.126:53947] from django.core.wsgi import get_wsgi_application
[Tue Sep 15 12:06:43.474799 2015] [:error] [pid 30226] [remote 172.31.14.126:53947] ImportError: No module named django.core.wsgi
Any idea what's wrong? 知道什么是错的吗?
Have you created a requirements.txt
in the root of your application? 您是否在应用程序的根目录中创建了
requirements.txt
? Elastic Beanstalk will automatically install the packages from this file upon deployment. Elastic Beanstalk将在部署时自动从此文件安装软件包。 (Note it might need to be checked into source control to be deployed.)
(注意,可能需要检查要部署的源代码控制。)
pip freeze > requirements.txt
(You will probably want to do that from within a virtualenv so that you only pick up the packages your app actually needs to run. Doing that with your system Python will pick up every package you've ever installed system-wide.) (您可能希望在virtualenv中执行此操作,以便您只获取应用程序实际需要运行的软件包。使用您的系统执行此操作Python将获取您在系统范围内安装的所有软件包。)
The answer ( https://stackoverflow.com/a/47209268/6169225 ) by carl-g is correct. carl-g的答案( https://stackoverflow.com/a/47209268/6169225 )是正确的。 One thing that got me was that
requirements.txt
was in the wrong directory. 有一件事让我觉得
requirements.txt
在错误的目录中。 Let's say you created a django project called mysite
. 假设你创建了一个名为
mysite
的django项目。 This is the directory in which you run the eb
command(s) --> make sure requirements.txt
is in this directory. 这是运行
eb
命令的目录 - >确保requirements.txt
在此目录中。
If you forget the .ebextensions folder you will get the same error. 如果忘记.ebextensions文件夹,您将收到相同的错误。
I was following along with a good simple (non Elastic Beanstalk) tutorial and missed step 3 & 4 of Elastic Beanstalk . 我正在关注一个简单的(非Elastic Beanstalk) 教程并错过了Elastic Beanstalk的第3步和第4步。
I was using Django 1.11 and Python 2.7 我使用的是Django 1.11和Python 2.7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.