小编rog*_*888的帖子

调试器不会在 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 如下所示。我尝试通过按绿色箭头和按 F​​5 来使用调试器,但似乎都没有使调试器正常工作。我的“launch.json”文件也如下所示。

你好.py:

msg = "Hello World!"
print(msg) # Breakpoint
Run Code Online (Sandbox Code Playgroud)

启动.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
        },
    ]
}
Run Code Online (Sandbox Code Playgroud)

我希望底部栏变成橙色,程序停止在第二行,让我可以检查预览窗格中的局部和全局变量。相反,当程序运行时,底部栏保持橙色 …

python visual-studio-code vscode-debugger

27
推荐指数
2
解决办法
1万
查看次数