Traceback (most recent call last):
File “C:\Users\ssd\Documents\VS Studio\manage.py”, line 11, 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 “C:\Users\ssd\Documents\VS Studio\manage.py”, line 22, in
main()
File “C:\Users\ssd\Documents\VS Studio\manage.py”, line 13, 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?
…
I tried to fix this issue for 10 hours without success, please someone help.
What are your configurations for the environment?
Have you created a virtual environment with python -m venv
and installed your dependencies there? If not, i suggest that you do this, or if you’re using some sort of project management tool (poetry, pdm, etc) that should run out of the box.
If you already have created the virtual environment, make sure that it’s activated on the shell console that’s open on visual studio code.
This documentation may help as well.
Additionally, it makes a difference whether you are doing your development directly in the Windows environment, or if you’re using a docker container, or WSL, or connecting to a remote system.
im using it on WIndows directly, what are the commands i should run, to make it work?
Alguno encontro la solucion ? estoy con el mismo problema . Graciasss
The best information I have found is in the docs at Python and Django tutorial in Visual Studio Code
1 Like
I had the same issue recently. So, checking the workspace in VS Code, I noticed that the django libraries were not included in venv/Lib.
So, through the VS Code terminal, I installed django again according to the instructions in https://code.visualstudio.com/docs/python/tutorial-django:
‘python -m pip install --upgrade pip’
‘python -m pip install django’
And then, running the command ‘python manage.py runserver’ through the VS Code terminal, the server started normally.