0

I started a project in django and everything was okay, but i closed my project and fews days later i tried to reopen, but this error appeared when i put the command "django-admin runserver" :

Traceback (most recent call last):
  File "c:\users\moren\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\moren\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\moren\Envs\myapp\Scripts\django-admin.exe\__main__.py", line 7, in <module>
  File "C:\Users\moren\Envs\myapp\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "C:\Users\moren\Envs\myapp\lib\site-packages\django\core\management\__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\moren\Envs\myapp\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\moren\Envs\myapp\lib\site-packages\django\core\management\commands\runserver.py", line 61, in execute
    super().execute(*args, **options)
  File "C:\Users\moren\Envs\myapp\lib\site-packages\django\core\management\base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "C:\Users\moren\Envs\myapp\lib\site-packages\django\core\management\commands\runserver.py", line 68, in handle
    if not settings.DEBUG and not settings.ALLOWED_HOSTS:
  File "C:\Users\moren\Envs\myapp\lib\site-packages\django\conf\__init__.py", line 82, in __getattr__
    self._setup(name)
  File "C:\Users\moren\Envs\myapp\lib\site-packages\django\conf\__init__.py", line 67, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

And when i put "python manage.py runserver" this appear :

c:\users\moren\appdata\local\programs\python\python37-32\python.exe: can't open file 'manage.py': [Errno 2] No such file or directory

if anyone can help me I would be very grateful

Gaëtan GR
  • 1,380
  • 1
  • 5
  • 21
  • Maybe you forgot to activate the virtual environment? – Marco Dec 11 '21 at 14:34
  • Does this answer your question? [ImproperlyConfigured: You must either define the environment variable DJANGO\_SETTINGS\_MODULE or call settings.configure() before accessing settings](https://stackoverflow.com/questions/26082128/improperlyconfigured-you-must-either-define-the-environment-variable-django-set) – Ankit Tiwari Dec 17 '21 at 12:15

1 Answers1

0

You need to cd into your project and run the command again, so in short the command python manage.py runserver should be executed where the module "manage.py" is located.

Gaëtan GR
  • 1,380
  • 1
  • 5
  • 21