2016-03-07 86 views
0

我正在將應用程序部署到ElasticBeanstalk,並且碰到了一個看起來很簡單的障礙。錯誤是有效的ImportError: No module named myapp.settings,但我無法弄清楚應該是什麼原因造成這個問題。我過去曾經部署過其他的django應用程序,並且沒有遇到過這個問題。Django:在myapp.settings上部署到ElasticBeanstalk導入錯誤

我已經安裝有不同於EB錯誤日誌下面還有我的manage.py和.ebextensions文件

errors from eb logs

[2016-03-07T03:10:29.648Z] INFO [3559] - [Application update/AppDeployStage0/EbExtensionPostBuild] : Starting activity... 
[2016-03-07T03:10:30.852Z] INFO [3559] - [Application update/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Starting activity... 
[2016-03-07T03:10:30.853Z] INFO [3559] - [Application update/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_Myapp] : Starting activity... 
[2016-03-07T03:10:31.824Z] INFO [3559] - [Application update/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_Myapp/Command 01_collectstatic] : Starting activity... 
[2016-03-07T03:10:31.894Z] INFO [3559] - [Application update/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_Myapp/Command 01_collectstatic] : Activity execution failed, because: Traceback (most recent call last): 
    File "Myapp/manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
    File "/opt/python/run/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line 
    utility.execute() 
    File "/opt/python/run/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 302, in execute 
    settings.INSTALLED_APPS 
    File "/opt/python/run/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 55, in __getattr__ 
    self._setup(name) 
    File "/opt/python/run/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 43, in _setup 
    self._wrapped = Settings(settings_module) 
    File "/opt/python/run/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 99, in __init__ 
    mod = importlib.import_module(self.SETTINGS_MODULE) 
    File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
    ImportError: No module named myapp.settings 
    (ElasticBeanstalk::ExternalInvocationError) 

manage.py

#!/usr/bin/env python 
import os 
import sys 

if __name__ == "__main__": 
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Sifhub.settings") 

    from django.core.management import execute_from_command_line 

    execute_from_command_line(sys.argv) 

.ebextensions/01-django_eb.config

option_settings: 
    "aws:elasticbeanstalk:application:environment": 
    DJANGO_SETTINGS_MODULE: "Myapp.settings" 
    PYTHONPATH: "/opt/python/current/app/Myapp:$PYTHONPATH" 
    "aws:elasticbeanstalk:container:python": 
    WSGIPath: "Myapp/Myapp/wsgi.py" 
    "aws:elasticbeanstalk:container:python:staticfiles": 
    "/static/": "subapp/static/" 

回答

2

我看到您的django應用程序名稱爲Sifhub,您的配置文件內容Myapp作爲您的應用程序名稱。

您的配置文件,最好應該是這樣的:

option_settings: 
    "aws:elasticbeanstalk:application:environment": 
    DJANGO_SETTINGS_MODULE: "Sifhub.settings" 
    PYTHONPATH: "/opt/python/current/app/Sifhub:$PYTHONPATH" 
    "aws:elasticbeanstalk:container:python": 
    WSGIPath: "Sifhub/wsgi.py" 
    "aws:elasticbeanstalk:container:python:staticfiles": 
    "/static/": "subapp/static/" 
相關問題