Visual Studio代码Python超时等待调试器连接

use*_*401 13 python debugging visual-studio-code

我正在使用Python运行visual studio代码教程,无法连接到调试器.当我搜索时,谷歌/ SO空无一人.通常我使用Anaconda和Jupyter,所以我在我激活的3.6虚拟环境中将Visual Studio Code连接到python.我尝试在我的虚拟环境中安装ptvsd,但这对我所看到的并没有什么影响.

我欢迎任何建议.屏幕截图如下.在底部截图中的launch.json

在此输入图像描述 在此输入图像描述

Luc*_*ath 25

打开lauch.json文件并添加以下配置:

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

为控制台指定"none"时,它将在调试器控制台中运行调试器,而不是在内部或外部终端中运行.

  • 截至2019年7月,“ none”不是控制台的有效选项。而是使用...“ console”:“ internalConsole” (4认同)
  • 截至 2022 年,“internalConsole”方法无法始终如一地工作。 (3认同)

Big*_*dMe 8

我今天遇到了同样的问题。我认为当调试器尝试连接到 Visual Studio 中的集成 PowerShell 终端时,这可能是连接问题。如果我改为使用外部终端来运行程序,那么它可以正常工作,并且调试器连接到外部终端,我可以完美地调试。这是我的外部终端启动条目launch.json

{
    "name": "Python: Terminal (external)",
    "type": "python",
    "request": "launch",
    "program": "${file}",
    "console": "externalTerminal"
},
Run Code Online (Sandbox Code Playgroud)


小智 7

我遇到过同样的问题。通过使用“integratedTerminal”修复。
ps.我的系统win7

{
            "name": "Debug",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/main.Py",
            "console": "integratedTerminal"
}
Run Code Online (Sandbox Code Playgroud)


Vla*_*den 6

我有同样的问题,所以我在settings.json文件中添加了以下行 :

{
    // to fix 'Timeout waiting for debugger connections'
    "python.terminal.activateEnvironment": false
}
Run Code Online (Sandbox Code Playgroud)

  • 距答案几年后,但此修复不起作用。 (2认同)