ModuleNotFoundError: No module named Django

In this Python Django Tutorial, we will discuss how to solve the ModuleNotFoundError: no module named Django, and we shall also cover the following topics:

  • No module named Django windows 10
  • No module named Django ubuntu
  • No module named Django macOS

No module named Django windows 10

In this section, we will learn how to solve the modulenotfounderror: no module named ‘django’ in windows 10.

No module named Django windows 10
ModuleNotFoundError: No module named Django

For this, firstly check whether you have pip installed or not, by simply writing the command pip in the python terminal. If you have then it’s fine, otherwise, from the internet download a python script called get-pip.py and save it to your local system.

Command:

# Check pip is installed or not

pip

Pip is the package insatller used to install packages from the Python Packages.

Try to be aware of location the file was saved and change the current directory from the command prompt to that location.

#If pip is not installed then

cd path_of_dir_of_get-pip_script

After this, install pip and run the get-pip.py script by writing the following command:

"python .\get-pip.py"

Now, to install Django with its dependencies type the following command:

pip install django

Your, error will be resolved. Or, if not resolved then check the following steps.

  • If you installed Django in a virtual environment, make sure it must be activated.
source venv/bin/activate
  • Make sure the Django version you’re installing is compatible with the Python version you have installed.
  • If you have a 64-bit version of Python installed, ensure sure Django is 64-bit as well. In the case of 32 bits, both must be 32 bits.
  • Make sure to include the path to Python in the PATH variable for system and environment variables.
  • Upgrade pip to the most recent version if it is out of date.
python -m pip install --upgrage pip
  • Make sure there are no errors in the import statement as well.

Read: Python Change Django Version

No module named Django ubuntu

In this section, we’ll learn to resolve the modulenotfounderror: no module named ‘django’ in ubuntu.

To resolve this error, you have to install Django. So, to install Django, firstly, update your locale package with apt:

sudo apt update

Next, check which version of Python you have installed. And make sure it should be compatible with both Ubuntu and Django.

python3 -V

And, in last install the Django through the APT package manager.

sudo apt install python3-django

If you want to install Django with pip, follow the command:

sudo pip install django

With the above steps, your error will be resolved.

Also, check: Python Django vs Pyramid

No module named Django macOS

In this section, we’ll learn to resolve the modulenotfounderror: no module named ‘django’ in macOS.

To resolve this error, you have to install Django. And, before installing Django must check Python is installed or not. If already installed install pip package, and if not installed install python first and then pip package also.

And, after this finally, install Django.

sudo pip install django

With the above steps, your error will be resolved.

You may also like to read the following Django tutorials.

In this Python Django Tutorial, we have discussed the Python Django no module Django and we have also covered the following topics:

  • No module named Django windows 10
  • No module named Django ubuntu
  • No module named Django macOS