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

3

8

My debugger doesn't even begin to run my code. I press F5, the debug tab opens, shows that it is loading, and after a while it says "Session-1 timed out waiting for debuggee to spawn" in a pop-up window. I'm using VS Code version 1.40.1, I have my virtual environment setup, and the debugger used to work, stopping at breakpoints and changing the color of the blue bar at the bottom of the screen. Issue appeared while messing with the open() function, but the debugger doesn't work with any file. I have seen and tried the solutions offered here and here. I don't use Conda, Jupyter, or any extensions besides the standard Python extension. Code:

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)

My 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: Arquivo Atual",
        "type": "python",
        "request": "launch",
        "program": "${file}",
        "console": "integratedTerminal"
    }
]
}
Catherincatherina answered 23/11, 2019 at 21:48 Comment(8)
Can you share your code...? Please see: minimal reproducible example.Winterkill
Sure thing. I believe the problem is not with the code itself, it runs fine without the debugger, but here it goes:Catherincatherina
Can you explain what your code is meant to do? What do those files look like?Winterkill
It is supposed to calculate the n-th Fibonacci number (starting from 1) and list it in a file. The file is just a simple .txt, and contains nothing but the numbers. The code checks whether the file already exists, and if it doesn't, a file is created with the first two numbers (1 and 2). Also, if the n-th number is already in the file, nothing is done. It was while I was working with this code that the debugger stopped working.Catherincatherina
Exact same thing happened to me. Suddenly debugger start showing the "Session-1 timed out waiting for debuggee to spawn" pop-up, after weeks that all worked perfectly fine.Dalia
Roled back to vscode version 1.36.1 and disabled auto-update (https://mcmap.net/q/127324/-how-to-downgrade-vscode). Now it is working again.Dalia
Will try downgrading. Thanks.Catherincatherina
This is a known issue in the recent ptvsd pre-release: github.com/microsoft/ptvsd/issues/1937Polecat
R
4

My solution is downgrade Python extension for Visual Studio Code. You can download from GitHub release. PTVSD release 2019.10.44104 is fine with VS Code 1.40.2. Unchecked Extensions: Auto Update/Auto Check Updates and install from VSIX manually.

Update: Newer version VS Code 1.41 fix this issue already.

Risinger answered 2/12, 2019 at 4:24 Comment(0)
P
1

I had the same error, and I solved this problem by setting DEBUGPY_PROCESS_SPAWN_TIMEOUT environment variable to a desired value.

So I just add export DEBUGPY_PROCESS_SPAWN_TIMEOUT=1200 to the ~/.profile and solved it.

For details, you can refer to this issue.

Ptosis answered 5/3 at 13:43 Comment(0)
H
0

the python version is conflict with python debugger version. Change an older python debugger version or python version.

Huntsman answered 22/6, 2022 at 3:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.