vscode debug python

1. Let me talk about the key points first, and set them through the menu items in the upper left corner:

File-->Preferences-->Settings

In the pop-up page, enter the path corresponding to your own python version. I use the conda environment, the version is pydev3.9, and it is set like this:

 2. Create a debugging environment launch.json

Click the triangle run button on the left to display the hyperlink create a launch.json file. Note that Run and Debug is useless at this time. You need to create a launch.json file first.

 Click the launch.json hyperlink, and select Python in the pop-up option

 Then modify launch.json to the following:

{
    "version": "0.2.0",
    "configurations":[
        {
            "name": "Python: main",          // 调试工程名: main
            "type": "python",
            "request": "launch",
            "console": "integratedTerminal",
            "justMyCode": true,
            "program": "main.py",            // 指定调试的文件
            "args":["param1", "param2"],     // 命令行参数
            "cwd": "${workspaceFolder}"
        }
    ]
}

After the creation is complete, click the small run triangle in the upper left corner,

 It can be found that the environment is first adjusted to conda pydev3.9, and then the debugger is run

 

Guess you like

Origin blog.csdn.net/luhouxiang/article/details/128426447