python - 调试器不会在 VS Code for Python 中的断点处停止
问题描述
我刚刚安装了 VS Code 和 Python 扩展,但我无法让调试器工作。每次我尝试使用调试器时,它都会跳过我设置的任何断点并像往常一样运行程序。
我在安装了 Python 3.7.3 和 Python 扩展的 Windows 10 PC 上使用 VS Code。我按照此处的说明(https://code.visualstudio.com/docs/python/python-tutorial)在 C:\python_work\hello 中创建了一个名为“hello”的测试文件夹并创建了一个名为“hello.py”的程序在那个文件夹里面。hello.py 如下所示。我尝试通过按绿色箭头和按 F5 来使用调试器,但似乎都没有使调试器正常工作。我的“launch.json”文件也如下所示。
你好.py:
msg = "Hello World!"
print(msg) # Breakpoint
启动.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}",
"console": "integratedTerminal",
"stopOnEntry": true
},
]
}
我希望底部栏变成橙色,程序在第二行停止,让我可以在预览窗格中检查局部和全局变量。相反,当程序运行时,底部栏保持橙色 1/2 秒,就好像我按下了“在终端中运行 Python 文件”一样,而没有在断点处停止。请帮忙!
解决方案
设置"justMyCode": false
使其在断点处停止:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"stopOnEntry": true,
"justMyCode": false
},
]
}
推荐阅读
- android - audioserver 错误阻止 android ROM 启动
- python - Ansible 基本动态清单
- java - 如何解决具有地图而不是有效的json错误请求的Java resttemplate帖子错误400
- java - 在firebase实时数据库中创建相同的节点
- java - SLF4J:未找到 SLF4J 提供程序
- spring-boot - 使用 AXL 的 Spring Boot 项目 (Maven) - NetBeans 找不到生成的 AXL 包/类
- intellij-idea - IntelliJ 更新到新版本失败
- android - android主屏幕上的网站快捷方式阻止在chrome中打开
- visual-studio-2019 - 有没有办法让 Premake 使用 Visual-Studio 项目模板?
- swift - 了解基于文档的应用程序中的核心数据