-2

I made a simple flappy bird game. I wanna convert it to .exe file, and I did it with pyinstaller but when I try to open the .exe file in the dist folder it says can't run script

I then copied my assets folder and pasted it into the dist folder, then too its not working.

How do I make it work?

zymic
  • 1
  • 3
  • seems like an issue with Your code. does it run fine normally? it could be to some modules not being initialized. What I suggest is that You one by one remove some parts of the code and each time create another `.exe` (so in total it will be quite a lot of files but You can just delete them after testing.) so continue removing blocks of code until the `.exe` file runs, then You will know where the issue is. basically create a [mre] but out of code that when compiled to `.exe` throws the error – Matiiss May 12 '21 at 08:36
  • 1
    Basically the first step is *"How can I see what is the error?"*. Then I think it will be an easy fix. The only problem is that you don't know what is the error. – D_00 May 14 '21 at 14:18

1 Answers1

0

If you are converting a .pyw file, then PyInstaller will only show the game window when you will run it.

If you want to convert a .py file, it will also show the Command Prompt.


If you are getting an error in the form of a message box, that means that an error has stopped your code. Because you converted a .pyw file, the error will not be shown in the Command Prompt. A message box will appear instead.

To see what was the error in a more explicit way, you can:

1. Convert your file from .py to .exe to see the error in the Command Prompt instead of in a message box.

Then, you can record your screen and see what was the error.

2. Show the message box by yourself

Before converting your file, edit it like that:

from tkinter.messagebox import showerror
try:

    # your ENTIRE code here

except Exception as error:
    showerror('Error detected', error)

This way the error will be shown in a Tkinter message box like that:


Common errors:

  • You forgot to put an image in the .exe directory
  • pygame.font.SysFont does not work: use pygame.font.Font instead and use a .ttf file (more information here)
  • exit() is not recognised, use quit() instead (why exit() is deprecated)
D_00
  • 1,440
  • 2
  • 13
  • 32