VS Code created or found your virtual environment — but it still is not using it?
A virtual environment can exist perfectly while VS Code is still using another interpreter. Activation and interpreter selection are related, but the selected Python executable is the strongest evidence.
Ask Python which executable is running right now.
If you expected .venv, the printed path should point inside that environment. In VS Code, run Python: Select Interpreter and choose the project environment.
python -c "import sys; print(sys.executable)"If the environment does not exist yet, create it from the intended Python.
After creation, select .venv in VS Code. A virtual environment does not have to be manually activated to be usable — you can also run its Python directly. On Windows PowerShell the activation script is .venv\Scripts\Activate.ps1; in cmd.exe it is .venv\Scripts\activate.bat.
python -m venv .venvRetest the exact problem — do not assume it is fixed.
The executable and prefix should point into the intended project environment. Then install packages from this interpreter using python -m pip install ...
python -c "import sys; print(sys.prefix); print(sys.executable)"Fix complete. 😎
You verified the result instead of stopping after a hopeful change. Save the working interpreter/version/environment details with the project so you can reproduce them later.
Back to Fixes →This guided fix follows current official documentation. ITFixLab does not execute commands for you; you stay in control of your machine.
VS Code Python environments ↗Python venv documentation ↗