vscode中使用debugpy

安装库

uv add debugpy

项目根目录中新建以下文件

  • .vscode/launch.json
  • .vscode/settings.json
    .vscode
    |-- launch.json
    `-- settings.json

    .vscode/launch.json

    {
      // 使用 IntelliSense 了解相关属性。 
      // 悬停以查看现有属性的描述。
      // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
      "version": "0.2.0",
      "configurations": [
          {
              "name": "Python 调试程序: 当前文件",
              "type": "debugpy",
              "request": "launch",
              "program": "${file}",
              "console": "integratedTerminal",
              "python": "${workspaceFolder}/.venv/Scripts/python.exe",
              "cwd": "${workspaceFolder}"
          }
      ]
    }

.vscode/settings.json

{
    "python.defaultInterpreterPath": "./.venv/Scripts/python.exe",
    "python.terminal.activateEnvironment": true,
    "python.terminal.activateEnvInCurrentTerminal": true
} 

打断点后在debug扩展中debug运行即可
image