I recently made an executable of a Python program with py2exe, and when I ran the executable, a command window appeared for a split second and then disappeared. My program itself never actually ran at all. Everything is still inside the dist folder, so I'm not sure what's actually wrong. Is there a solution for this?
Asked
Active
Viewed 2,850 times
1 Answers
1
If all your program does is print something and you run it by double-clicking the executable, then it simply closes the console when it finishes running. If you want the window to stay open, run your program from the command line. You can also create a batch file that runs your program and then pauses the console, so that you at least get a "press any key" before the console closes.

TigerhawkT3
- 48,464
- 6
- 60
- 97
-
That's not what it was, I'm afraid. The program creates a GUI, so the command window shouldn't show up at all, I don't think. However, I'm new with Python. – TimeWillTell Apr 05 '15 at 03:22
-
1I believe Tigerhawk is correct. The program probably encountered an exception (maybe py2exe didn't bundle everything correctly), printed out the traceback, and then stopped. You should try running it from the console and see if there's a traceback. – Gustav Apr 05 '15 at 03:52
-
Yes! I ran in in the console and it told me the problem, and it's now fixed. Thank you both! – TimeWillTell Apr 05 '15 at 03:55
-
If either of you are still here, though, could you tell me how to prevent the command window from coming up along with my GUI when I run the executable? I'd love to know as long as it's not an inconvenience for you. – TimeWillTell Apr 05 '15 at 03:59
-
1Use pythonw (.pyw extension). https://docs.python.org/2/using/windows.html#executing-scripts – Gustav Apr 05 '15 at 04:14