[英]ModuleNotFoundError: No module named 'django' while deploying to ElasticBeanstalk
Tried multiple solutions online but couldnt get it working ! 在线尝试了多种解决方案,但无法使其正常运行! Basically my application is deployed but http response is "Internal Server Error". 基本上我的应用程序已部署,但http响应是“内部服务器错误”。 On investigating EB logs i found the following traceback. 在调查EB日志时,我发现了以下追溯。
[Sat Jun 08 10:28:56.880823 2019] [:error] [pid 4776] [remote 172.31.4.251:180] Traceback (most recent call last):
[Sat Jun 08 10:28:56.880846 2019] [:error] [pid 4776] [remote 172.31.4.251:180] File "/opt/python/current/app/modelforms/modelforms/wsgi.py", line 12, in <module>
[Sat Jun 08 10:28:56.880863 2019] [:error] [pid 4776] [remote 172.31.4.251:180] from django.core.wsgi import get_wsgi_application
[Sat Jun 08 10:28:56.880878 2019] [:error] [pid 4776] [remote 172.31.4.251:180] ModuleNotFoundError: No module named 'django'
[Sat Jun 08 10:29:10.828039 2019] [:error] [pid 4776] [remote 172.31.42.54:180] mod_wsgi (pid=4776): Target WSGI script '/opt/python/current/app/modelforms/modelforms/wsgi.py' cannot be loaded as Python module.
[Sat Jun 08 10:29:10.828089 2019] [:error] [pid 4776] [remote 172.31.42.54:180] mod_wsgi (pid=4776): Exception occurred processing WSGI script '/opt/python/current/app/modelforms/modelforms/wsgi.py'.
My requirements.txt is placed in all directories and yet django module is not recognised. 我的requirements.txt放在所有目录中,但无法识别django模块。 It seems it hasn't been installed at first place. 它似乎还没有安装在第一位。 The file's contents are: 该文件的内容是:
Django==2.2.1
Pillow==6.0.0
pytz==2019.1
sorl-thumbnail==12.5.0
sqlparse==0.3.0
Any help is appreciated. 任何帮助表示赞赏。
EDIT1: I dont have ebextentions setup, however the same config's are present when i run " eb config" 编辑1:我没有设置ebextentions,但是当我运行“eb config”时,会出现相同的配置
aws:elasticbeanstalk:container:python:
NumProcesses: '1'
NumThreads: '15'
StaticFiles: /static/=static/
WSGIPath: modelforms/modelforms/wsgi.py
aws:elasticbeanstalk:container:python:staticfiles:
/static/: static/
aws:elasticbeanstalk:environment:
EnvironmentType: LoadBalanced
ExternalExtensionsS3Bucket: null
ExternalExtensionsS3Key: null
LoadBalancerType: application
ServiceRole: aws-elasticbeanstalk-service-role
Try adding your DJANGO_SETTINGS_MODULE and PYTHONPATH to the config 尝试将DJANGO_SETTINGS_MODULE和PYTHONPATH添加到配置中
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "modelforms.settings"
"PYTHONPATH": "/opt/python/current/app/modelforms:$PYTHONPATH"
Also, check the Health dashboard and make sure it shows as deployed before testing 此外,请检查运行状况仪表板,并确保在测试之前将其显示为已部署
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.