I am working on a python editor/ide and I have been using os.startfile(file_path) to run the files but because this is like starting them using python.exe the console closes as soon as the file finishes running or it runs into an error.
I am looking for a method of running python files that has them behaving normally (like ran with idle/visual studio code), but the console output still being visible after it finishes running or crashes so I can see the error messages and the print() output.
This method can't hold up the python script that started it so that the tkinter interface I am using doesn't freeze.
input()at the end of the code executed by the console, so it doesn't automatically close when finished.os.startfile()is absolutely inappropriate to run a Python file. It opens the file with the default application, which for security reasons should not be the Python interpreter directly. Check thesubprocessmodule to run programms or make the code you are calling a function and run it in a thread.