Python中使用vscode配置Delve调试器时遇到报错如何解决

2017/10/17 12:43:29 server.go:73: Using API v1 2017/10/17 12:43:29 debugger.go:97: launching process with args: [/Users/kevin/go/src/learning_go/debug] could not launch process: exec: "lldb-server": executable file not found in $PATH Process exiting with code: 1


Python中使用vscode配置Delve调试器时遇到报错如何解决

2 回复

我最近也在VS Code里配Delve调试Go项目,Python调试其实更简单。如果你在Python项目里配Delve,那可能是搞混了——Delve是Go语言的调试器,Python用的是debugpy。

对于Python调试,正确配置应该是这样的:

  1. 安装debugpy(Python的调试器):
pip install debugpy
  1. VS Code配置.vscode/launch.json):
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": false
        }
    ]
}
  1. 如果要用远程调试
import debugpy
debugpy.listen(5678)  # 监听端口
debugpy.wait_for_client()  # 等待调试器连接
# 你的代码从这里开始
  1. 常见问题解决
  • 如果报“无法连接到调试器”,检查端口是否被占用
  • 确保VS Code安装了Python扩展
  • 虚拟环境问题:在VS Code里选对Python解释器(Ctrl+Shift+P → “Python: Select Interpreter”)

如果你确实需要在VS Code里调试Go代码,那才需要Delve,配置完全不同。但既然你问的是Python项目,用debugpy就对了。

一句话建议:Python调试用debugpy,别用Delve。


This error can show up for Mac users using delve of version 0.12.2 or above. Not sure why, but doing a xcode-select --install has solved the problem for users who have seen this issue.

回到顶部