How to stop Python closing immediately when executed in Microsoft Windows
How to stop Python closing immediately when executed in Microsoft Windows
In Python 3, add the following to the end of your code:
input(Press ENTER to exit)
This will cause the program to wait for user input, with pressing ENTER causing the program to finish.
You can double click on your script.py
file in Windows conveniently this way.
The only thing that worked for me -i command line argument.
Just put all your python code inside a .py file and then run the following command;
python -i script.py
It means that if you set -i variable and run your module then python doesnt exit on SystemExit.
Read more at the this link.
How to stop Python closing immediately when executed in Microsoft Windows
Open your cmd (command prompt) and run Python commmands from there.
(on Windows go to run or search and type cmd)
It should look like this:
python yourprogram.py
This will execute your code in cmd and it will be left open.
However to use python command, Python has to be properly installed so cmd recognizes it as a command. Checkout proper installation and variable registration for your OS if this does not happen