我正在向ElasticBeanstalk部署一个应用程序,并且看起来非常简单。该错误实际上是ImportError: No module named myapp.settings
,但我无法弄清楚应该导致此问题的原因。我以前部署了其他具有相同设置的django应用程序,之前没有遇到过这个问题。
我在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/"
答案 0 :(得分:3)
我看到您的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/"