VS Code Python Debugger "timed out waiting for debuggee to spawn"



我的调试器甚至没有开始运行我的代码。我按 F5,调试选项卡打开,显示它正在加载,过了一会儿,它在弹出窗口中显示"会话 1 超时等待调试对象生成"。我使用的是 VS Code 版本 1.40.1,我设置了虚拟环境,调试器曾经工作过,在断点处停止并更改屏幕底部蓝色条的颜色。弄乱 open(( 函数时出现问题,但调试器不适用于任何文件。 我已经看到并尝试了这里和这里提供的解决方案。我不使用 Conda、Jupyter 或标准 Python 扩展以外的任何扩展。 法典:

import os
def fib(n):
if not os.path.exists("Fibfile.txt"):
with open("Fibfile.txt", "w") as file:
file.write("1n2n")
with open("Fibfile.txt", "r") as file:
contents = file.readlines()
data = []
for item in contents:
# removes newline
data.append(int(item[:-1]))
with open("Fibfile.txt", "a") as file:
if n <= len(data):
return
else:
while n > len(data):
data.append(data[-2]+data[-1])
file.write(f"{data[-1]}n")
fib(100)

我的启动.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: Arquivo Atual",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}

我的解决方案是降级Visual Studio Code的Python扩展。 您可以从 GitHub 版本下载。 PTVSD 版本 2019.10.44104 适用于 VS Code 1.40.2。 未选中的扩展:自动更新/自动检查更新 并手动从 VSIX 安装。

更新:较新版本 VS Code 1.41 已经修复了此问题。

python版本与python调试器版本冲突。 更改较旧的 python 调试器版本或 python 版本。

最新更新