Issue
I am working on a Django project and this is what I am getting when I try to run the server. It used to work totally fine but I think the path is missing for virtualenv. I installed anaconda yesterday and the path variable is changed in advanced system settings. How can I revert them back to original settings? Total python newbie here. Kindly help.
C:\Users\13157\django_project>python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 9, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 20, in <module>
main()
File "manage.py", line 11, in main
raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
C:\Users\13157\django_project>
Solution
If you already have the virtual environment created that has django installed, do: path_to_environment_folder\Scripts\activate
.
If you don't have an existing environment, create one by using python3 -m venv environment
and then activate it with environment\Scripts\activate
. After that, install django with pip3 install django
.
Answered By - theoctober19th