2017-10-21 171 views
0

我想部署在heroku上,但首先我試圖在我的機器上運行,但我一直收到模塊未找到錯誤。我的目錄結構是這樣的:未找到模塊錯誤:沒有模塊命名'my_project.settings'django gunicorn

enter image description here

爲了使它更清楚,我有一個叫做「imperialtheatre」文件夾中保存VENV和要求,該文件夾內我稱之爲「imperialtheatre」,其保存的文件夾與manage.py等django項目

爲什麼我得到這個錯誤?

我運行這個命令:

gunicorn imperialtheatre.imperialtheatre.wsgi:application -t 120 -w 8 -k gevent --max-requests 250 --log-level debug

wsgi.py文件:

import os 

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "imperialtheatre.settings") 
from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application() 

from whitenoise.django import DjangoWhiteNoise 
application = DjangoWhiteNoise(application) 

回答

0

假設你有所在的設置文件夾中的設置文件。更改

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "imperialtheatre.settings") 

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "imperialtheatre.settings.settings_file") 

更換settings_file與實際設置文件的名稱。

還要確保設置目錄中有一個__init__.py文件。如果沒有,只需在那裏保存一個名爲__init__.py的空白文件。

相關問題