为什么VSCode不能在断点处停止以进行调试?

4

我知道之前有一篇关于这个问题的发帖:Debugger Not Stopping at Breakpoints in VS Code for Python

然而,在更新的 VSCode 上我遇到了完全相同的问题。

我的环境配置如下:

  • Manjaro Linux
  • Official MS VSCode (1.55.2)
  • Python Extension added, and mostly at defaults (below are my settings.json settings related to python)
    "[python]": {
        "editor.detectIndentation": true,
        "editor.insertSpaces": true
    },
    "python.autoComplete.addBrackets": true,
    "python.linting.flake8Args": [
        "--ignore=F401,F841,E501,E305,E302"
    ],
    "python.linting.flake8Enabled": true,
    "python.venvPath": "/home/greg/git/code/python/venvs"
    
  • Here are my launch.json settings:
    {
        // 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: Debug Current File",
                "type": "python",
                "request": "launch",
                "program": "${file}",
                "console": "integratedTerminal",
                "stopOnEntry": true,
                "justMyCode": false
            }
        ]
    }
    

有一些 Python 代码不会生成 Python VM 指令,它们被优化掉了。如果没有这种代码的产物,我们就无法帮助您。请反汇编出存在问题的最小代码。 - rioV8
我甚至只是放了一个简单的“print("Hello World")”,仍然出现相同的问题。 - GregTheHun
请尝试使用VSCode Insider - Molly Wang-MSFT
1个回答

2

尝试:

  1. 从项目中删除 launch.json 文件(如果需要,将其保存在其他地方)
  2. 重新启动 VS Code
  3. 尝试调试。如果提示您需要 launch.json 文件,请选择默认选项。

尝试了几个建议后,这个起作用了!谢谢 - Harvey Mushman

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接