Pyinstaller compiled app closes instantly, then reopens & works (macOS)

166 views Asked by At

I have compiled a Python script with a Tkinter GUI using Pyinstaller.

When trying to open my app, it adds the app to the dock for a split second, then closes it and reopens after about 10-20 seconds (Then it runs completely normal).

This only happens when I use the --onefile --windowed option, using --onedir --windowed the app just opens immediately and stays open. I would prefer using my app as --onefile --windowed without it opening, closing, and reopening though.

gif animation of application opening, closing and reopening

My setup: macOS (Ventura 13.1) Python 3.9.18 PyInstaller 6.0.0 pyinstaller-hooks-contrib 2023.9

I tried all sorts of different PyInstaller options but I can't find the problem

In case it might help identify the problem, here is my PyInstaller command:

python -m PyInstaller --noconfirm --noconsole --onedir --clean --icon "/Users/ugn/Documents/Code/Commercial/overtitle/overtitle-build/favicon.icns" --add-data "/Users/ugn/Documents/Code/Commercial/overtitle/overtitle-build/env/lib/python3.9/site-packages/iso639:iso639/" --add-data "/Users/ugn/Documents/Code/Commercial/overtitle/overtitle-build/templates:templates/" --add-data "/Users/ugn/Documents/Code/Commercial/overtitle/overtitle-build/static:static/" main.py
1

There are 1 answers

4
fgo On BEST ANSWER

When using PyInstaller in one file mode, the app unzips all the data to a temporary folder before the app runs, the delay is that happening. See here.

This can be fixed by not using onefile mode, or trying another Python to exe program.