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

2024-05-20 20:26:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用Python运行visual studio代码教程,无法连接到调试器。当我搜索时,Google/SO将变成空的。通常我在Jupyter中使用Anaconda,所以我将Visual Studio代码连接到我激活的3.6虚拟环境中的python。我试着在我的虚拟环境中安装ptvsd,但这并没有改变我所看到的。

我欢迎任何建议。以下是截图。底部截图中的launch.json

enter image description hereenter image description here


Tags: 代码sogoogle虚拟环境jupyter教程anacondalaunch
3条回答

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

{
     "name": "Python: Debug Console",
     "type": "python",
     "request": "launch",
     "program": "${file}",
     "console": "internalConsole"
}

当您为控制台指定noneinternalConsole时,它将在调试器控制台中运行调试器,而不是在内部或外部终端中运行。

我也有同样的问题,所以我在 settings.json文件:

{
    // to fix 'Timeout waiting for debugger connections'
    "python.terminal.activateEnvironment": false
}

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

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

相关问题 更多 >