ModuleNotFoundError:部署到ElasticBeans时没有名为“Django”的模块

2024-04-19 06:52:46 发布

您现在位置:Python中文网/ 问答频道 /正文

尝试了多种在线解决方案,但无法使其工作! 基本上我的应用程序是部署的,但是http响应是“内部服务器错误”。 在调查电子商务日志时,我发现了以下回溯。你知道吗

[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'.

我的要求.txt被放置在所有目录中,但django模块未被识别。好像一开始还没有安装。 文件内容包括:

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

感谢您的帮助。你知道吗

编辑1: 我没有ebextensions设置,但是当我运行“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




Tags: pyawsappwsgiremotestaticerrorcurrent
1条回答
网友
1楼 · 发布于 2024-04-19 06:52:46

尝试将DJANGO\u设置\u模块和PYTHONPATH添加到配置中

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

另外,检查健康仪表板,确保它在测试前显示为已部署

相关问题 更多 >