2016-10-07 28 views
2

使用Python 3.5和1.9 Django的,我嘗試部署我的應用程序pythonanywhere,但我不斷收到此錯誤Pythonanywhere - 導入錯誤:沒有模塊名爲「myapp.settings」

2016-10-07 01:44:28,879 :Error running WSGI application 
Traceback (most recent call last): 
    File "/bin/user_wsgi_wrapper.py", line 154, in __call__ 
    app_iterator = self.app(environ, start_response) 
    File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application 
    raise e 
    File "/bin/user_wsgi_wrapper.py", line 154, in __call__ 
    app_iterator = self.app(environ, start_response) 
    File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application 
    raise e 
    File "/bin/user_wsgi_wrapper.py", line 179, in <module> 
    application = load_wsgi_application() 
    File "/bin/user_wsgi_wrapper.py", line 175, in load_wsgi_application 
    return __import__(os.environ['WSGI_MODULE'], globals(), locals(), ['application']).application 
    File "/var/www/nidalmer_pythonanywhere_com_wsgi.py", line 21, in <module> 
    application = StaticFilesHandler(get_wsgi_application()) 
    File "/home/nidalmer/trailersapp/myvenv/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application 
    django.setup() 
    File "/home/nidalmer/trailersapp/myvenv/lib/python3.5/site-packages/django/__init__.py", line 17, in setup 
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) 
    File "/home/nidalmer/trailersapp/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 55, in __getattr__ 
    self._setup(name) 
    File "/home/nidalmer/trailersapp/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 43, in _setup 
    self._wrapped = Settings(settings_module) 
    File "/home/nidalmer/trailersapp/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 99, in __init__ 
    mod = importlib.import_module(self.SETTINGS_MODULE) 
    File "/home/nidalmer/trailersapp/myvenv/lib/python3.5/importlib/__init__.py", line 126, in import_module 
    return _bootstrap._gcd_import(name[level:], package, level) 
ImportError: No module named 'trailersapp.settings' 

這裏是我的WSGI的.py文件

import os 

import sys 

path = '/home/nidalmer/trailersapp/trailers/settings.py' 

if path not in sys.path: 
    sys.path.append(path) 

from django.core.wsgi import get_wsgi_application 

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

application = get_wsgi_application() 

和我的樹:

trailersapp 
├── db.sqlite3 
├── manage.py 
├── movies 
│ ├── __init__.py 
│ ├── __pycache__ 
│ ├── admin.py 
│ ├── apps.py 
│ ├── forms.py 
│ ├── migrations 
│ ├── models.py 
│ ├── templates 
│ ├── tests.py 
│ ├── urls.py 
│ └── views.py 
├── myvenv 
├── requirements.txt 
├── static 
│ ├── admin 
│ └── movies 
└── trailers 
    ├── __init__.py 
    ├── __pycache__ 
    ├── settings.py 
    ├── urls.py 
    └── wsgi.py 

我無法知道錯誤來自哪裏,因爲我的wsgi文件顯示trailers.settings而不是trailersapp.settings,而且我沒有那個地方。

任何幫助,將不勝感激!

回答

4

wsgi文件中的路徑錯誤。它應該是路徑到您的應用程序,所以:

path = '/home/nidalmer/trailersapp' 

另外,我認爲你在尋找一個老回溯或WSGI文件的舊副本。確保它們都是最新的。

+0

是的,事實證明我正在看一個wsgi的舊版本,我糾正它,一切都是爲了謝謝你! – mari

相關問題