Joh*_*ith 10 python debugging visual-studio-code
在Python项目中,如何告诉内置VSCode调试器在执行时进入其他库的函数代码?
我知道在标准库中实现的功能可以通过添加
"debugOptions": ["DebugStdLib"]
Run Code Online (Sandbox Code Playgroud)
到此处指定的launch.json中的配置,但是似乎无法强制调试器进入非标准模块的代码,例如您自己编写并导入到当前文件中的模块。
Den*_*loe 26
这是通过自定义调试器来完成的。
如果还没有,您需要初始化调试器自定义。您可以通过打开侧栏中的调试器部分并选择 来完成此操作create a launch.json file。
完成此操作后,launch.json将在工作区的文件夹中创建一个文件.vscode。
编辑此文件。它看起来像这样:
{
...,
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
Run Code Online (Sandbox Code Playgroud)
添加"justMyCode": false到"Python: Current File"配置中,如下所示:
{
...,
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false
}
]
}
Run Code Online (Sandbox Code Playgroud)
从 Visual Studio Code 版本 1.59.0 开始为 true。
参考: https: //code.visualstudio.com/docs/python/debugging
小智 16
为了改善约翰·史密斯所接受的答案,值得一提的是,现在该选项已重新命名。新选项是
"justMyCode": false
Run Code Online (Sandbox Code Playgroud)
并根据文档
如果省略或设置为True(默认值),则仅将调试限制为用户编写的代码。设置为False还可以启用标准库功能的调试。
调试器配置
"debugOptions": ["DebugStdLib"]
Run Code Online (Sandbox Code Playgroud)
实际上,在launch.json中添加的内容将进入用户定义的和 pip 安装的模块,这与主要问题中所写的相反。
launch.json 文件中的配置如下对我有用。
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "test",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false,
"purpose": ["debug-in-terminal"]
}
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1729 次 |
| 最近记录: |