VS Code 中等待启动器连接超时

Sus*_*san 6 python connection-timeout vscode-debugger

我在 VS code 中进行了 python 调试。以下是launch.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",
            "stopOnEntry": false,
            "python": "${command:python.interpreterPath}",
            "program": "${file}",
            "cwd": "${workspaceFolder}",
            "env": {},
            "envFile": "${workspaceFolder}/.env",
            "debugOptions":[
                "RedirectOutput"
            ],
            "console": "integratedTerminal"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

以下是settings.json文件:

{
    "python.pythonPath": "c:\\Users\\susan\\Documents\\PythonScripts\\venv\\Scripts\\python.exe",
    // to fix 'Timeout waiting for debugger connections'
    "python.terminal.activateEnvironment" : false
}
Run Code Online (Sandbox Code Playgroud)

当我在 VS code 中调试 python 脚本时,我得到了Time out waiting for launcher to connect但无法调试 python 脚本。

我可以知道如何解决这个问题吗?

小智 6

非常简单。打开该launch.json文件并将以下内容添加到其中:

{
  "name": "Python: Debug Console",
  "type": "python",
  "request": "launch",
  "program": "${file}",
  "console": "internalConsole"
}
Run Code Online (Sandbox Code Playgroud)

然后保存并退出。无论您做什么,都不要清除其中已有的文本,否则可能会使情况变得更糟