Python exe file auto closes after double-clicked

1.6k Views Asked by At

I've converted a python script to an exe file using pyinstaller, whenever I open the exe the program, it flashes for a second and automatically shuts down itself.

The program is a simple one. Here's the code snippet:

print("Hello World")
2

There are 2 best solutions below

0
cocool97 On

Add something like input("Press something to exit") or time.sleep(10) function at the end of your programm to have a standby at the end of the main function

4
deeBo On

If for whatever reason you can't or don't want to edit the code, you may be able to see the output of the compiled version by opening the file from the command prompt.

cd /D C:\location\of\the\file
myFile.exe