Python ModuleNotFoundError: No module named django














































Python ModuleNotFoundError: No module named django



Python ModuleNotFoundError: No module named 'django'


Django is open source web application framework written in python. It offers big collection of modules which can be used in projects. If you were getting this error, which means you haven't installed django.




If you were using ubuntu, run the following on terminal:


sudo pip install django

wait until the process is done and type 'import django'



It works.

If you have to install django with its version number, run the following command on terminal:


sudo pip install "django==*version_number*"

for example:

sudo pip install "django==1.10"

If you're using virtual environment:


Before you get to install django, activate virtual environment.  It can be done by running 
following commands in terminal.

for installing virtual environment:

sudo apt-get install python-virtualenv

To create and activate virtual environment:

virtualenv *env_name*
source *env_name*/bin/activate



And then install django

pip install django

Note:  If you're using virtual environment, don't use 'sudo' while installing django.





Comments