Fix the Can't Open File 'manage.py': [Errno 2] No Such File or Directory Error in Python

Fix the Can't Open File 'manage.py': [Errno 2] No Such File or Directory Error in Python

Every Django project has a few automatically created Python scripts. The django-admin.py script file provides command-line utilities for administrative tasks.

The manager.py file is similar to the django-admin.py script and is automatically created. It also performs additional tasks of setting the value of the DJANGO_SETTINGS_MODULE environment variable to the path of the settings.py script file of the project.

It also puts the path of the project’s package on the sys.path.

This tutorial will discuss the below error in Python and how to fix it:

python: can't open file 'manage.py': [Errno 2] No such file or directory

Fix the Can't Open File 'manage.py': [Errno 2] No Such File or Directory Error in Python

This error can be seen while running the python manage.py runserver command.

It is caused because we are not in the project’s root directory. The manager.py file is in the root directory, and we need to be in this directory while running the command.

We cannot be in any project subdirectory and expect this command to run.

To fix this, redirect to the root directory using the cd command and run the command. It should work fine.

Author: Manav Narula
Manav Narula avatar Manav Narula avatar

Manav is a IT Professional who has a lot of experience as a core developer in many live projects. He is an avid learner who enjoys learning new things and sharing his findings whenever possible.

LinkedIn

Related Article - Python Error

  • Local Variable Referenced Before Assignment Error in Python
  • Python Handling Socket.Error: [Errno 104] Connection Reset by Peer
  • Python Is Not Recognized in Windows 10
  • NameError: The OS Module Is Not Defined in Python
  • Python ValueError: Not Enough Values to Unpack
  • Resolve the TypeError: Can't Multiply Sequence by Non-Int of Type STR in Python