Modulenotfounderror: no module named ‘django’

In this article, we will give the solutions to this modulenotfounderror: no module named django error in Windows, Anaconda, and a JUPYTER notebook.

Why the error occur?

The no module named django error occurs because the python interpreter is unable to find the installed ”django” module in python library.

Also read: [SOLVED] Modulenotfounderror: no module named ‘mysql’

How to solve the modulenotfounderror: no module named django?

To solve the error, we need install the module by executing this command: pip install Django.

Time needed: 3 minutes

Here are the solutions to solve this error in windows, anaconda, and Jupyter Notebook

  • Solution 1: Install in Python 2

    This is the command to install in virtual environment or in Python 2:
    pip install Django

  • Solution 2: Install in Python 3

    This is the command to install in Python 3:
    pip3 install Django

  • Solution 3: Installation of Getting Permission Error

    This is the command to install if you are getting permission error:
    sudo pip3 install Django
    or
    pip install Django –user

  • Solution 4: Install pip in your PATH environment variable in Python 2 and Python 3

    This is the command to install pip in your PATH environment variable:
    python -m pip install Django
    and install pip in your PATH environment variable in Python 3:
    python3 -m pip install Django

  • Solution 5: Install in py alias (Windows)

    This is the command to install in py alias (Windows):
    py -m pip install Django

  • Solution 6: Install in Anaconda

    This is the command to install in Anaconda:
    conda install -c anaconda django

  • Solution 7: Install in Jupyter Notebook

    This is the command to install in Jupyter Noebook:
    !pip install Django

After the installation of Django Module, you are supposed to be able to use and import it.

The typical Cause of Error’s:

These are the typical reasons that the “django modulenotfounderror no module named“:

  1. The “django” package is not installed.
  2. You installed the package in a numerous python version compared to the one you’re using.
  3. You installed the module globally not within your virtual environment.
  4. You run the IDE within an incorrect python version.

If the error continue, check your Python version and assured you are installing the module using the correct Python version.

Also you may read: Modulenotfounderror: no module named rest_framework [SOLVED]

Like this the example below:

Type this command to check you python version: “python –version

Modulenotfounderror: no module named 'django' python version

In the above example, the version of my Python is 3.10.5. So I need to install Django Module with pip3.10 install Django.

Type this command to install python version 3.10:

pip3.10 install Django

Checked the Packaged if it is Installed

We can check if we have the Django package installed in our system by executing this command:

pip3 show Django

After you execute the pip3 show Django, it will show the name, version, summary, home-page, and license etc. or either the system will show the package is not installed.

Modulenotfounderror: no module named 'django' pip3 show Django

Reinstalled the Package

When the error can’t resolved, we will try to uninstall the Django module and then install it again.

Step 1: Uninstall Django

Type this command to uninstall the Django:

pip3 uninstall Django

Step 2: if you don’t set up pip in PATH environment variable.

Type this command to uninstall the pip Django:

python3 -m pip uninstall Django

Step 3: Install Django again

pip3 install Django

Conclusion

In conclusion of this article, if you encountered this error “django no module named” the given solutions above is the best way to solve or fix your problem.

Leave a Comment