VSCode python 'Unverified breakpoint' 在调试期间?
VSCode python 'Unverified breakpoint' during debugging?
我正在使用 VSCode 调试我的 python 应用程序。
我有一个主要的 python 文件,用于启动调试器。我可以在这个文件中放置断点,但是如果我想在主文件调用的其他文件中放置断点,我将它们设置为 'Unverified breakpoint' 并且调试器会忽略它们。
如何更改 launch.json
以便能够在项目中的所有文件上放置断点?
这是我当前的launch.json
:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}"
},
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}",
"port": 3000,
"secret": "my_secret",
"host": "localhost"
},
{
"name": "Python: Terminal (integrated)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Terminal (external)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "externalTerminal"
},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"debugOptions": [
"RedirectOutput",
"Django"
]
},
{
"name": "Python: Flask (0.11.x or later)",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "${workspaceFolder}/app.py"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
]
},
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "nf.session.session"
},
{
"name": "Python: Pyramid",
"type": "python",
"request": "launch",
"args": [
"${workspaceFolder}/development.ini"
],
"debugOptions": [
"RedirectOutput",
"Pyramid"
]
},
{
"name": "Python: Watson",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/console.py",
"args": [
"dev",
"runserver",
"--noreload=True"
]
},
{
"name": "Python: All debug Options",
"type": "python",
"request": "launch",
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"module": "module.name",
"env": {
"VAR1": "1",
"VAR2": "2"
},
"envFile": "${workspaceFolder}/.env",
"args": [
"arg1",
"arg2"
],
"debugOptions": [
"RedirectOutput"
]
}
]
}
谢谢
其他模块的导入在字符串中,并使用 execute
函数调用。这就是为什么 VSCode 无法确定其他文件中的断点,因为它不知道主文件使用了这些其他文件..
这可能是“justMyCode”配置选项的结果,因为它默认为 true。
虽然提供者的描述是“...仅对用户编写的代码进行调试。设置为 False 以同时启用对标准库函数的调试。”,我认为他们的意思是网站中的任何内容- 当前 python 环境的软件包将不会被调试。
我想调试 Django 堆栈以确定源自我的代码的异常在何处被吞噬而不浮出水面,因此我对 VSCode 的调试器的启动配置执行了此操作:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Control Center",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver",
"--noreload"
],
"justMyCode": false, // I want to debug through Django framework code sometimes
"django": true
}
]
}
我一这样做,调试器就删除了 "Unverified breakpoint" 消息,并允许我调试我正在处理的虚拟环境的站点包中的文件,其中包含 Django。
我应该注意到,调试器的断点部分给了我一个关于为什么断点未被验证以及对启动配置进行哪些调整的提示:
另外一个注意事项:“--noreload”参数也很重要。在使用 Flask 调试不同的应用程序时,调试器不会在任何断点处停止,直到我将它添加到启动配置中。
我正在使用 VSCode 调试我的 python 应用程序。
我有一个主要的 python 文件,用于启动调试器。我可以在这个文件中放置断点,但是如果我想在主文件调用的其他文件中放置断点,我将它们设置为 'Unverified breakpoint' 并且调试器会忽略它们。
如何更改 launch.json
以便能够在项目中的所有文件上放置断点?
这是我当前的launch.json
:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}"
},
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}",
"port": 3000,
"secret": "my_secret",
"host": "localhost"
},
{
"name": "Python: Terminal (integrated)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Terminal (external)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "externalTerminal"
},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"debugOptions": [
"RedirectOutput",
"Django"
]
},
{
"name": "Python: Flask (0.11.x or later)",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "${workspaceFolder}/app.py"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
]
},
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "nf.session.session"
},
{
"name": "Python: Pyramid",
"type": "python",
"request": "launch",
"args": [
"${workspaceFolder}/development.ini"
],
"debugOptions": [
"RedirectOutput",
"Pyramid"
]
},
{
"name": "Python: Watson",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/console.py",
"args": [
"dev",
"runserver",
"--noreload=True"
]
},
{
"name": "Python: All debug Options",
"type": "python",
"request": "launch",
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"module": "module.name",
"env": {
"VAR1": "1",
"VAR2": "2"
},
"envFile": "${workspaceFolder}/.env",
"args": [
"arg1",
"arg2"
],
"debugOptions": [
"RedirectOutput"
]
}
]
}
谢谢
其他模块的导入在字符串中,并使用 execute
函数调用。这就是为什么 VSCode 无法确定其他文件中的断点,因为它不知道主文件使用了这些其他文件..
这可能是“justMyCode”配置选项的结果,因为它默认为 true。
虽然提供者的描述是“...仅对用户编写的代码进行调试。设置为 False 以同时启用对标准库函数的调试。”,我认为他们的意思是网站中的任何内容- 当前 python 环境的软件包将不会被调试。
我想调试 Django 堆栈以确定源自我的代码的异常在何处被吞噬而不浮出水面,因此我对 VSCode 的调试器的启动配置执行了此操作:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Control Center",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver",
"--noreload"
],
"justMyCode": false, // I want to debug through Django framework code sometimes
"django": true
}
]
}
我一这样做,调试器就删除了 "Unverified breakpoint" 消息,并允许我调试我正在处理的虚拟环境的站点包中的文件,其中包含 Django。
我应该注意到,调试器的断点部分给了我一个关于为什么断点未被验证以及对启动配置进行哪些调整的提示:
另外一个注意事项:“--noreload”参数也很重要。在使用 Flask 调试不同的应用程序时,调试器不会在任何断点处停止,直到我将它添加到启动配置中。