Reputation: 335
Using Python 3.5 and Django 1.9, I was trying to deploy my app to pythonanywhere, but I keep getting this error
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'
Here is my wsgi.py file
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()
and my tree:
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
I can't tell where the error is coming from since my wsgi file says trailers.settings and not trailersapp.settings and I don't have that anywhere.
Any help would be appreciated!
Upvotes: 2
Views: 2043
Reputation: 5776
The path in your wsgi file is wrong. It's supposed to be the path to your app, so:
path = '/home/nidalmer/trailersapp'
Also, I think you're looking at an old traceback or an old copy of the wsgi file. Make sure they're both up-to-date.
Upvotes: 3