Search code examples
pythonpython-idle

Python IDLE shell restarting


When I run my code, it prints out the values I tell it to but it does it rarely.

and majority of the time it restarts the shell after a few seconds.

it just says: ============= RESTART: Shell =============

I try to run the code a few time but it rarely executes it fully.


Solution

  • The IDLE GUI process runs your code in a separate user-code execution process, with a socket connection. When the GUI process loses contact with the execution process, it starts a new execution process and displays the RESTART line to let you know what happened. The connection loss is nearly always because your code caused python in the execution process to crash and vanish.

    You first should run your code without IDLE from a console/terminal/CommandPrompt window and see if it either runs okay or displays some error message before crashing. Running okay is unlikely but faintly possible. If it still crashes, you have to debug the problem, which you can do running from an IDLE editor. For that, read, for example, https://stackoverflow.com/help/mcve, to isolate the problem as much as possible.