I built a simple "flappy bird" game with pygame and then tried to convert the .py script with pyinstaller into an .exe with pyinstaller flappybird.py
. But when I try to execute the .exe, the command prompt and the game window open for about 2 seconds without displaying any errors and without showing anything from the game, which works fine when executed as python script via flappybird.py
in the command prompt. I am using the newest version of pyinstaller and I don´t have any idea why this isn´t working, since it worked like a charm with other games I wrote before.
Thanks for your help ;D
Best Answer
Try opening a command prompt and navigating to the folder you installed it. Then run it via
flappybird.exe
(or whatever you titled it) and check that the error doesn't show up within your terminal. It sounds like it hits an error that crashes it, but immediately closes before you can read the error. Therefore running it from terminal allows it to have a window that doesn't disappear and it can print an error message there if there is one (this may only tell you errors during startup though, I'm not sure). I typically prefer to use a GUI that has a section of text that updates and I can use this to essentially "print" statuses of my compiled programs into this box, perhaps you could use a similar technique? Best of luck!update
With your code I was able to compile it and run it with no problems (using cx-freeze). My setup.py file was:
You can get your executable working if you
pip install cx_freeze
copy/paste the code above into a file
setup.py
(placed right next to your script)open folder in command prompt and run
python setup.py build
You may need to run the command again if it fails (something to do with trying to read from a folder it hasn't made yet).
build
and your executable is inside it!