繁体   English   中英

ModuleNotFoundError:部署到ElasticBeanstalk时没有名为'django'的模块

[英]ModuleNotFoundError: No module named 'django' while deploying to ElasticBeanstalk

在线尝试了多种解决方案,但无法使其正常运行! 基本上我的应用程序已部署,但http响应是“内部服务器错误”。 在调查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'.

我的requirements.txt放在所有目录中,但无法识别django模块。 它似乎还没有安装在第一位。 该文件的内容是:

Django==2.2.1
Pillow==6.0.0
pytz==2019.1
sorl-thumbnail==12.5.0
sqlparse==0.3.0

任何帮助表示赞赏。

编辑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



尝试将DJANGO_SETTINGS_MODULE和PYTHONPATH添加到配置中

  "aws:elasticbeanstalk:application:environment":
    DJANGO_SETTINGS_MODULE: "modelforms.settings"
    "PYTHONPATH": "/opt/python/current/app/modelforms:$PYTHONPATH"

此外,请检查运行状况仪表板,并确保在测试之前将其显示为已部署

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM