Pythonanywhere - ImportError:没有名为' myapp.settings'

时间:2016-10-07 02:31:01

标签: python django pythonanywhere

使用Python 3.5和Django 1.9,我试图将我的应用程序部署到pythonanywhere,但我一直收到此错误

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而我无法在任何地方找到错误,因此无法判断错误来自何处。

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:4)

wsgi文件中的路径错误。它应该是您应用的路径,所以:

path = '/home/nidalmer/trailersapp'

另外,我认为您正在查看旧的回溯或wsgi文件的旧副本。确保它们都是最新的。