I am able to activate the venv in terminal from VSCode in the console using venv/Scripts/activate
command.
I can run the python script in the terminal
But when I try to Debug the same script in VSCode, it does not run in the Venv and I get missing dependency errors.
What are the steps to enable the venv when debugging Python in VSCode
The only instructions I can find are using "Python: Select Interpreter" settings
Is this the same as activating the virtual environment?
Do I just point it to venv/Scripts/Python.exe
and it will work without activating anything?
2
Answers
When you select an interpreter, VSCode will use the associated environment with all the installed libraries.
If you’ve already created the virtual environment, you can simply select it using the
Python: Select Interpreter
command from the Command Palette (⇧⌘P). That will "activate" it, meaning VSCode will use this instead of any other Python installation. If you don’t see it in the list, click on "Enter interpreter path…" and paste the path to the python file in the environment you created.More information here.
You can configure the interpreter path using
python
in launch.jsonThen start debugging in the Run and Debug panel