pythonpython-3.xwindowsloopspythoninterpreter

Python loop keeps stopping in Window's interpreter


I'm using the default Python 3.8 interpreter in Windows.

Whenever I run a long loop in it, it'll stop and I have to press or hold down the Enter key for it to keep going. This was never a problem in Linux.

How do I fix this behavior?

# this loop will eventually stop/hang/pause forever, until I press the Enter key
for i in range(5000):
   time.sleep(1)
   print(i)

If I run the code through any IDE, it doesn't pause. But I want to run this particular code directly in the interpreter for my own reasons.

I took this screenshot after waiting more than 1 minute for it to continue. This isn't a once off problem. ANY loop I run, no matter how small or big or complex, will permanently stop after a few iterations until I press the ENTER key on my keyboard.

enter image description here

enter image description here

enter image description here


Solution

  • The console will pause the script if you click on the output, it will try to stop the code to "select" a part of the output. give it a try without clicking it. ENTER will remove focus from the select bar on the console, so you will see that the it's not there anymore.