Tkinter program converted to .app using PyInstaller closes immediately Tkinter program converted to .app using PyInstaller closes immediately tkinter tkinter

Tkinter program converted to .app using PyInstaller closes immediately


RoberR seems like you are missing some necessary packages while building app from pyInstaller, I would suggest your to use:

pyinstaller --onefile --icon favicon.icns --name Battleship battleship.py 

it will display your terminal and you would be able to figure out what is happening, in case of missing package please use:

pyinstaller --onefile --hidden-imports=file_name --icon favicon.icns --name Battleship battleship.py

Hope this solves your problems.


It is definitely an issue with Tkinter that crash when using the doubleclick on the .app. The only workaround I found was to use "brew python3" instead of "anaconda python3".


Reposting myself from: https://stackoverflow.com/a/57818744/10143204

There is a few issues with the tcl version that comes with python, discussed here. I've written an script that automatically changes the init.tcl file to the correct version.

N.B. you shouldn't use the --onefile flag as the file directories aren't present, and the script won't work.

  1. cd /path/of/your/app
  2. git clone https://github.com/jacob-brown/TCLChanger.git
  3. pyinstaller --windowed app.py
  4. python TCLChanger/TCLChanger.py

You should now be able to open your app, from the terminal and via double clicking.