小编Ped*_*lia的帖子

VS Code Python 调试器“等待调试对象生成超时”

我的调试器甚至没有开始运行我的代码。我按 F5,调试选项卡打开,显示它正在加载,过了一会儿,它在弹出窗口中显示“Session-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("1\n2\n")
    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)
Run Code Online (Sandbox Code Playgroud)

我的启动.json:

{
// Use IntelliSense to learn about possible attributes.
// Hover to …
Run Code Online (Sandbox Code Playgroud)

python debugging timeout visual-studio-code

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

debugging ×1

python ×1

timeout ×1

visual-studio-code ×1