Search code examples
djangowsgipythonanywhere

PythonAnywhere WSGI error


in spite of my best efforts in the past weeks I've been stuck at deploying the WSGI file on Pythonanywhere while trying to set up a django framework. There are similar topics on here, but none were adoptable to my case.

I'm following this tutorial and I get the following error message:

2017-03-04 22:28:05,284 :Error running WSGI application
2017-03-04 22:28:05,285 :ImportError: No module named 'mysite'
2017-03-04 22:28:05,285 :  File "/var/www/iamcsongor_pythonanywhere_com_wsgi.py", line 11, in <module>
2017-03-04 22:28:05,285 :    application = get_wsgi_application()
2017-03-04 22:28:05,285 :
2017-03-04 22:28:05,285 :  File "/home/iamcsongor/my-first-blog/myvenv/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
2017-03-04 22:28:05,285 :    django.setup(set_prefix=False)
2017-03-04 22:28:05,285 :
2017-03-04 22:28:05,285 :  File "/home/iamcsongor/my-first-blog/myvenv/lib/python3.5/site-packages/django/__init__.py", line 22, in setup
2017-03-04 22:28:05,286 :    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2017-03-04 22:28:05,286 :
2017-03-04 22:28:05,286 :  File "/home/iamcsongor/my-first-blog/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 53, in __getattr__
2017-03-04 22:28:05,286 :    self._setup(name)
2017-03-04 22:28:05,286 :
2017-03-04 22:28:05,286 :  File "/home/iamcsongor/my-first-blog/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 41, in _setup
2017-03-04 22:28:05,287 :    self._wrapped = Settings(settings_module)
2017-03-04 22:28:05,287 :
2017-03-04 22:28:05,287 :  File "/home/iamcsongor/my-first-blog/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 97, in __init__
2017-03-04 22:28:05,287 :    mod = importlib.import_module(self.SETTINGS_MODULE)

Here's my WSGI file:

import os

import sys

path = '/home/iamcsongor/my-first-blog/firstweb'  # use your own PythonAnywhere username here
if path not in sys.path:
    sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler
application = StaticFilesHandler(get_wsgi_application())

I've taken a few screenshots of the code and Git Repo, if you could help, I'd be grateful. Thanks


Solution

  • As the error says, your DJANGO_SETTINGS_MODULE environment variable is set to "mysite", but that directory does not exist. Your settings file actually appears to be in "firstweb".