首页 > 解决方案 > 在 macOS Catalina 上使用“使用进程 ID 附加”在 VSCodium 中调试 Python 超时

问题描述

我正在尝试将 VSCodium(基本上是没有 MS 跟踪的 VSCode)附加到正在运行的进程,但不断收到“等待调试服务器连接超时”错误消息。里面的日志~/.vscode-oss/extensions/ms-python.python-2020.8.105369不再提供更多信息。

该文档看起来应该可以正常工作,并且之前已经为其他人工作过。macOS Catalina (10.15.7) 中是否发生了一些变化,可能是权限问题?还是我完全错过了其他东西?

这是我的launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Attach using Process Id",
            "type": "python",
            "request": "attach",
            "processId": "${command:pickProcess}",
            "logToFile": true
        }
    ]
}

标签: pythonvisual-studio-code

解决方案


不知道我当时做了什么,但现在这行得通:

  1. 将以下内容添加到代码中:

    import debugpy
    debugpy.listen(5678)
    debugpy.wait_for_client()
    debugpy.breakpoint()
    
  2. 运行

  3. 使用 VSCodium 的“Attach using Process Id”并搜索运行代码


推荐阅读