Takahiro  Funahashi
Takahiro Funahashi

Reputation: 282

How to use the Python debugger in venv in VScode on Windows?

OS:Windows10Pro

IDE:VScode Ver1.59.0

Python:Ver 3.9.6

I created a virtual environment with venv and selected python.exe on the virtual environment with "select interpreter". Even if I specify a breakpoint on a simple script and execute debug (F5), the breakpoint will be ignored and executed.

In Ubuntu 20.04 on VMware, I debugged in the same way using VScode Ver1.59.0, so it will stop at the breakpoint.

In both Windows and Ubuntu, I didn't specify the path in launch.json or setting.json.

I specified the Python path in launch.json on Windows, but the debugger doesn't work.

Is this a bug specific to the Windows environment? Or am I forgetting to set something?


1.python -m venv [ENV_NAME]

2.Open Folder [ENV_NAME] on VScode

3.Open Terminal

4../Script/activate

5.create python script

a=0
print(a) #<-set berak point

6.select interpreter -> ./Script/python.exe

7.press F5(run debug)

Upvotes: 1

Views: 6871

Answers (1)

Takahiro  Funahashi
Takahiro Funahashi

Reputation: 282

I didn't understand that VScode on Windows had to create an ENV folder directly under the workspace folder.

Curiously, on Ubuntu, the debugger works even if the ENV folder is a workspace folder.


1.Create a project folder

2.Open project folder on VScode

3.Open Terminal

4.cd project folder

5.create venv (python -m venv [ENV_NAME])

6../[ENV_NAME]/Script/acitivate

7.create python script

8.select interpreter -> ./[ENV_NAME]/Script/python.exe

9.press F5(run dubug)

Upvotes: 3

Related Questions