[Python] Spyder is hanging in debug mode

Discussão em 'Python' iniciado por Stack, Agosto 20, 2025.

  1. Stack

    Stack Membro Participativo

    After starting in Spyder the code

    print("Hello World!")
    breakpoint()


    by pressing F5 we land in debug mode. After pressing F5 twice more, Spyder hangs, and the only way to restart the code is to restart the kernel with the awkward combination Ctrl + . that must be confirmed by Enter. What is the purpose of this behavior, and how can it be avoided? Why is the user able to provoke a crash?

    I want to note that starting the code with F5 is a common task, and Spyder hangs depending on whether the current state is debug mode. This behavior cannot be avoided because it is not visible at first glance when debug mode is active. Also, I always mistakenly think that the debug mode can be closed by F5, but instead must be closed by another awkward Ctrl+Shift+F12. Finally you always have to be careful about when to press F5 and when to press Ctrl+Shift+F12; otherwise, Spyder will hang.

    Using raise SystemExit is not an alternative as the variable of a function is not accessible after stopping.

    def f1():
    t=1
    raise SystemExit

    def f2():
    t=1
    breakpoint()

    f1() # t is not accessible after stopping
    f2() # t is accessible after stopping


    The problem was also issued at Github.

    Spyder 6.07, Win10

    Continue reading...

Compartilhe esta Página