没有模块命名设置错误django弹性beantalk

问题描述 投票:0回答:1

我正在尝试将Django应用程序部署到弹性beantalk。加载settings时,Beanstalk找不到wsgi.py文件。我在其他一些SO问题中也看到了这一点,但这些问题都没有解决我的问题。

我收到以下错误:

ModuleNotFoundError: No module named 'kairos_app.prod_settings'
Target WSGI script '/opt/python/current/app/kairos_app/kairos_app/wsgi.py' cannot be loaded as Python module.

这些是02_python.config.ebextensions文件的内容:

container_commands:
  01_migrate:
    command: "source /opt/python/run/venv/bin/activate && python3 kairos_app/manage.py migrate --noinput"
    leader_only: true
  02_collectstatic:
    command: "source /opt/python/run/venv/bin/activate && python3 kairos_app/manage.py collectstatic --noinput"

option_settings:
  "aws:elasticbeanstalk:application:environment":
    DJANGO_SETTINGS_MODULE: "kairos_app.prod_settings"
    "PYTHONPATH": "/opt/python/current/app/kairos_app:$PYTHONPATH"
  "aws:elasticbeanstalk:container:python":
    WSGIPath: kairos_app/kairos_app/wsgi.py
  "aws:elasticbeanstalk:container:python:staticfiles":
    "/static/": "www/static/"

这是目录结构的样子:

enter image description here

似乎可以选择WSGIPath,所以我不确定为什么不能选择django设置模块路径。

django amazon-elastic-beanstalk
1个回答
0
投票

它可能正在寻找父kairos_app目录。

尝试更改

DJANGO_SETTINGS_MODULE: "kairos_app.prod_settings"

进入

DJANGO_SETTINGS_MODULE: "kairos_app.kairos_app.prod_settings"

OR

"PYTHONPATH": "/opt/python/current/app/kairos_app:$PYTHONPATH"

进入

"PYTHONPATH": "/opt/python/current/app/kairos_app/kairos_app:$PYTHONPATH"

后者会影响整个运行时,因此可能会破坏事情。

© www.soinside.com 2019 - 2024. All rights reserved.