mmoomocow
mmoomocow

Reputation: 1227

No module named 'djangosite' when trying to use manage.py

I am using Django 3.0 and python 3.7 to run my Django server, it has only just stopped working and was working before.

The full error is here That was running python3 manage.py runserver and it is the same for any commands with manage.py

I have tried with and without my virtual environment and have reinstalled Django but it hasn't changed

the only place where djangosite is mentioned is in manage.py which I haven't changed

#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangosite.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)


if __name__ == '__main__':
    main()

Django is installed and I can run other sites

File tree is here

Upvotes: 1

Views: 385

Answers (2)

mmoomocow
mmoomocow

Reputation: 1227

I had incorrect file structure. The settings.py was in the main folder with manage.py It should have been in the mysite folder that has the main urls.py etc.

I fixed it by just re-creating the Django project and copying my apps and static file directory

Upvotes: 1

Vladimir Osintsev
Vladimir Osintsev

Reputation: 106

You don't have Django installed or it is not available in your PYTHONPATH.

Perhaps you just did not activate your virtualenv in command shell.

Upvotes: 0

Related Questions