Django ModuleNotFoundError: No module named 'ecomprj' on PythonAnywhere Deployment

Body:

I am deploying my Django project on PythonAnywhere, but I keep getting this error in my logs:

ModuleNotFoundError: No module named 'ecomprj'

Project Structure:

My Django project is located at:
/home/Sagarmoy007/django_ecom_web/ecomprj/

Running ls -l /home/Sagarmoy007/django_ecom_web/ecomprj gives:

__pycache__  core  customercare  db.sqlite3  deladmin  ecomprj  errorriders  
locustfile.py  manage.py  media  migrate.bat  notification_app  others  requirements.txt  
returnadmin  staffdata  static  staticfiles  templates  useradmin  userauths  
vendorpannel  videoshareing  whoosh_index

Inside /home/Sagarmoy007/django_ecom_web/ecomprj/ecomprj/, I have:

__init__.py  settings.py  urls.py  wsgi.py  asgi.py

My WSGI File (/var/www/sagarmoy007_pythonanywhere_com_wsgi.py):

import os
import sys

# Add the correct project paths
sys.path.append('/home/Sagarmoy007/django_ecom_web/ecomprj')  # The main directory
sys.path.append('/home/Sagarmoy007/django_ecom_web/ecomprj/ecomprj')  # The Django project folder

# Set Django settings module
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ecomprj.settings')

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

What I Have Tried:

  1. Verified that manage.py exists inside /home/Sagarmoy007/django_ecom_web/ecomprj.
  2. Checked that the Django settings module is correctly set (ecomprj.settings).
  3. Restarted the web app from the PythonAnywhere dashboard.
  4. Ran python manage.py shell inside /home/Sagarmoy007/django_ecom_web/ecomprj, but it fails with the same ModuleNotFoundError.

Questions:

  1. Is my WSGI configuration correct?
  2. Do I need to modify my PythonAnywhere environment?
  3. How can I properly set up Django on PythonAnywhere to recognize my project?

Here is the full traceback in python anywhere

2025-03-05 17:05:34,895: Error running WSGI application
2025-03-05 17:05:34,898: ModuleNotFoundError: No module named 'ecomprj'
2025-03-05 17:05:34,898:   File "/var/www/sagarmoy007_pythonanywhere_com_wsgi.py", line 17, in <module>
2025-03-05 17:05:34,899:     application = get_wsgi_application()
2025-03-05 17:05:34,899: 
2025-03-05 17:05:34,899:   File "/usr/local/lib/python3.10/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2025-03-05 17:05:34,899:     django.setup(set_prefix=False)
2025-03-05 17:05:34,900: 
2025-03-05 17:05:34,900:   File "/usr/local/lib/python3.10/site-packages/django/__init__.py", line 19, in setup
2025-03-05 17:05:34,900:     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2025-03-05 17:05:34,900: 
2025-03-05 17:05:34,901:   File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 87, in __getattr__
2025-03-05 17:05:34,901:     self._setup(name)
2025-03-05 17:05:34,901: 
2025-03-05 17:05:34,901:   File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 74, in _setup
2025-03-05 17:05:34,901:     self._wrapped = Settings(settings_module)
2025-03-05 17:05:34,902: 
2025-03-05 17:05:34,902:   File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 183, in __init__
2025-03-05 17:05:34,902:     mod = importlib.import_module(self.SETTINGS_MODULE)
Вернуться на верх