Forums

Error running WSGI application & ModuleNotFoundError: No module named 'django'

Hello, I am pretty new to using pythonanywhere and I seem to be running into an error every time. The error shows ModuleNotFoundError: No module named 'django' even though I have clearly reran the pip install django method into the virtualenv. It is also giving me the error of Error running WSGI application even though I should have theoretically, correctly linked my WSGI path to the correct source. I am very confused and lost.

Help would be much appreciated :)

This is one of the error that keeps coming up.

  • 2022-11-07 15:53:54,168: Error running WSGI application 2022-11-07 15:53:54,169: ModuleNotFoundError: No module named 'django'
  • 2022-11-07 15:53:54,170: File "/var/www/jhn01_pythonanywhere_com_wsgi.py", line 26, in <module>
  • 2022-11-07 15:53:54,170: from django.core.wsgi import get_wsgi_application 2022-11-07 15:53:54,170:

  • 2022-11-07 15:53:54,170: If you're seeing an import error and don't know why,
  • 2022-11-07 15:53:54,171: we have a dedicated help page to help you debug:
  • 2022-11-07 15:53:54,171: https://help.pythonanywhere.com/pages/DebuggingImportError/
  • 2022-11-07 15:53:54,171:

I am aware that I should import django but I did and it still kept giving me the same error.

Hi there -- I just looked at the logs that we can see from our side, and it looks like you've fixed that issue but are running into a new one where it can't find your settings file. The important thing for that is to check that your WSGI file, when it appends a directory to the system path, appends the specific directory that contains your manage.py file. If you can't get that to work, you can post your WSGI file and a description of your directory structure here and I'm sure we'll be able to help.

Great, got it to work! I swear I tried this method before uploading it to the forum but I don't know why it's working now haha.

Cheers :)

Glad to hear that!