Forums

Error running WSGI application, ModuleNotFoundError: No module named 'foody'

Hey guys, I have been stuck on this error for a couple of hours trying all sorts of solutions to no avail.. Could someone kindly swoop in and help? Thank you in advance, ay communication is appreciated.

My wsgi file..

import os
import sys

root_path = os.path.abspath(os.path.split(__file__)[0])
sys.path.insert(0, os.path.join(root_path, 'foodypeeps'))
sys.path.insert(0, root_path)

# add your project directory to the sys.path
path = "/home/alexkiriungi/foodypeeps/foodie/"

# set environment variable to tell django where your settings.py is
os.environ["DJANGO_SETTINGS_MODULE"] = "foody.settings"


# serve django via WSGI
from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler

application = StaticFilesHandler(get_wsgi_application())

The error logs..

2023-10-17 10:00:18,583: Error running WSGI application
2023-10-17 10:00:18,591: ModuleNotFoundError: No module named 'foody'
2023-10-17 10:00:18,592:   File "/var/www/alexkiriungi_pythonanywhere_com_wsgi.py", line 29, in <module>
2023-10-17 10:00:18,592:     application = StaticFilesHandler(get_wsgi_application())
2023-10-17 10:00:18,592: 
2023-10-17 10:00:18,593:   File "/home/alexkiriungi/myvenv/lib/python3.10/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2023-10-17 10:00:18,593:     django.setup(set_prefix=False)
2023-10-17 10:00:18,593: 
2023-10-17 10:00:18,593:   File "/home/alexkiriungi/myvenv/lib/python3.10/site-packages/django/__init__.py", line 19, in setup
2023-10-17 10:00:18,593:     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2023-10-17 10:00:18,593: 
2023-10-17 10:00:18,594:   File "/home/alexkiriungi/myvenv/lib/python3.10/site-packages/django/conf/__init__.py", line 102, in __getattr__
2023-10-17 10:00:18,594:     self._setup(name)
2023-10-17 10:00:18,594: 
2023-10-17 10:00:18,594:   File "/home/alexkiriungi/myvenv/lib/python3.10/site-packages/django/conf/__init__.py", line 89, in _setup
2023-10-17 10:00:18,594:     self._wrapped = Settings(settings_module)
2023-10-17 10:00:18,594: 
2023-10-17 10:00:18,594:   File "/home/alexkiriungi/myvenv/lib/python3.10/site-packages/django/conf/__init__.py", line 217, in __init__
2023-10-17 10:00:18,595:     mod = importlib.import_module(self.SETTINGS_MODULE)

Assuming that your settings module is located at /home/alexkiriungi/foodypeeps/foodie/foody, you should fix your wsgi file, as you're not currently inserting the path to the sys.path.