Sometimes, we want to fix ImportError: Couldn’t import Django with Python Django.
In this article, we’ll look at how to fix ImportError: Couldn’t import Django with Python Django.
How to fix ImportError: Couldn’t import Django with Python Django?
To fix ImportError: Couldn’t import Django with Python Django, we create a virtualenv and then we install the django` package in the virtualenv.
To create the virtualenv, we run
sudo pip3 install virtualenv
Then we go to the virtualenv by running
$ virtualenv newenv
$ source newenv/bin/activate
and then we run
pip install django
to install the django
package.
Conclusion
To fix ImportError: Couldn’t import Django with Python Django, we create a virtualenv and then we install the django` package in the virtualenv.