我最近开始学习编程(Python)并正在使用 VSCode。我刚刚重新启动计算机,现在无法在 VSCode 中运行 python 脚本。 通常,当我在 VSCode 中打开 python 脚本时,我可以按 F5,我的脚本将在终端面板中运行,显示脚本的输出 (PowerShell 7.4.5)。 重新启动计算机并尝试在 VSCode 中运行脚本后,调试器面板现在打开,几秒钟后我收到一条弹出消息,显示“等待启动器连接超时”。我不记得过去打开过调试器面板,我的脚本输出只会显示在终端面板中。我不知道重新启动计算机是否运行了更改设置的更新,或者也许我在不知情的情况下更改了某些内容?
以下是我发现可能导致问题的设置。我使用下面列出的 stackoverflow 链接来尝试找到解决方案。
这是我的 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 Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
在我的settings.json 中,我有以下两行,我认为它们可以解决 stackoverflow 上回答的其他问题中的问题:
"code-runner.runInTerminal": true
和
"debug.internalConsoleOptions": "neverOpen"
这里是 settings.json 的“终端”部分中的所有设置。
"window.zoomPerWindow": false,
"editor.fontSize": 18,
"terminal.integrated.fontSize": 18,
"python.interpreter.infoVisibility": "always",
"terminal.integrated.defaultLocation": "editor",
"terminal.integrated.tabs.defaultColor": "terminal.ansiGreen",
"window.zoomLevel": 2,
"code-runner.runInTerminal": true,
"debug.internalConsoleOptions": "neverOpen",
"terminal.integrated.automationProfile.windows": {}
我在 Stackoverflow 上找到并尝试了以下建议:
“然后只需搜索在终端中运行的代码运行程序,您将看到一个启用在终端中运行功能的选项,将其打开。” 我确保在我的设置中将其设置为“true”。
"code-runner.runInTerminal": true,
无法在 vscode 中运行代码,它不会在终端部分向我显示它,而是将我发送到输出部分
我打开了终端面板并更改为与我运行的脚本相同的目录,然后尝试按 F5,但它仍然打开调试器,然后超时。 无法在 vscode 中运行代码,它不会在终端部分向我显示它,而是将我发送到输出部分
我尝试关闭“调试模式”,但重新启动 VSCode 后问题仍然存在。
"debug.internalConsoleOptions": "neverOpen"
如何在 VS-Code 中关闭或关闭调试模式
我已确保控制台设置为“integratedTerminal”
"console": "integratedTerminal"
VS code 中等待启动器连接超时
我也尝试过设置
"console" to "internalConsole"
但我仍然有同样的问题。我已将设置改回
"integratedTerminal"
我已确保关闭所有打开的终端并重新启动 VSCode,但问题仍然存在。 尝试在 vscode 中调试 python 文件时超时
试试这个
{
“版本”:“0.2.0”,
“配置”:[
{
"name": "Python 调试器:当前文件",
“类型”:“蟒蛇”,
“请求”:“启动”,
"程序": "${文件}",
"console": "集成终端",
“justMyCode”:假,
“logToFile”:正确,
"pythonPath": "${workspaceFolder}/venv/bin/python" // 替换为正确的 python 解释器路径
}
]
}