Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python manage.py runserver error : ModuleNotFoundError: No module named 'settings'

I am in the process on getting started with python and have run into a problem using django 2.1 and python 3.7 that many other people seem to have had as well.

Below is my process for getting here:

  • started a virtual environment

  • started a django project

  • attempted to run:

python manage.py runserver

I consistently get the error : ModuleNotFoundError: No module named 'settings'

I've researched extensively to and came across a few solutions in the following SO questions, none of which were effective solutions for me. Has anyone come across this issue?

First question researched

Second Question researched

Any insight would be helpful. Thanks in advance.

EDIT: my manage.py file looks like this:

#!/usr/bin/env python import os import sys

if __name__ == '__main__':
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mytodoapp.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)

my file structure looks like :

mytodoapp

mytodoapp

>__init__.py

>settings.py

>urls.py

>wsgi.py

manage.py

Screenshot of my console

Manage.py file

like image 304
N00b_Overflow Avatar asked Dec 06 '25 23:12

N00b_Overflow


1 Answers

  1. open yr project folder.

  2. search for the wsgi.py file and add this line.

    from django.conf import settings.
    
  3. Then save.

  4. locate yr manage.py file edit the

    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'projectname.settings')
    

    To

    os.environ['DJANGO_SETTINGS_MODULE' ]='projectname.settings'
    
  5. save and walla problem fixed.

  6. cd to yr app folder and then runserver with

    python manage.py runserver. 
    
like image 142
XerxesCodes Avatar answered Dec 08 '25 13:12

XerxesCodes