0

This is a common problem, though the solutions seem diverse and none have helped me.

Like this question and this question, on mac, my PyInstaller .app fails to open when clicked on in Finder. However it does work when launched from the terminal ./helloWorldTest.app/Contents/MacOS/helloWorldTest. The .exe file does works when clicked on in Finder (which from my reading also seems common).

Unlike the apps in the linked questions, my app does not read or write any files: I have entirely gutted my actual app (which has the same problematic behaviour) to a simple hello world version:

# This is a trivial app with a loop to ensure it stays open long enough to actually see something happen before the script finishes.   
 print('hello world!')
    
    i = 0
    while i < 1000000:
        print('hello world number: ', i)
        i += 1

While >90% of the solutions to similar sounding problems all involve changing paths, that can't be the issue here as there is essentially nothing to this app. So, can anyone help me get this basic app working so I can build & debug from there?

Here is the PyInstaller command I use: pyinstaller helloWorldTest.py --onefile --icon=dipyIcon.icns -w --clean

SeánMcK
  • 392
  • 3
  • 17
  • 1
    Not completely sure why this got downvoted. Feels like a fair question (particularly given how common the issue is)- I understand there are rules to posting 'good' questions, but without a comment or context a downvote is just a slap in the face. Which is frustrating, and frankly a little rude. – SeánMcK Nov 22 '20 at 15:26

1 Answers1

0

Kinda surprising got given how seemingly prevalent this issue is. Anyway, for anyone searching/googling this in the future, hopefully this will help. The issue is caused by the default version of something called Tcl that is used in your bundled app. The latest version for some reason doesn't work, so you need to manually set it to a slightly older version.

Note: This solution was found by manuelf23, I am only relaying it here. You can find the original thread here

To do this:

  1. Right click your .app file (the one with the icon, you have given it one)

  2. Click Show package contents (You're now in the hidden files that are bundled together. These files sit in a standard OSX structure, which is the same architecture as any app on a mac

  3. Navigate to this file: ./Contents/Resources/tcl/init.tc [note, you do not use the --onefile flag otherwise you'll only have your icon in the Resources folder]

  4. Open the init.tc file in any text editor and go to line 19

  5. On line 19 you'll find this line (package require -exact Tcl 8.6.8) and replace it with package require -exact Tcl 8.5.9 - or put simply change the Tcl version to 8.5.9

  6. Et Voilà, vous êtes au top- go back to your app and double click your icon

Just in case, here's the PyInstaller command I used:

pyinstaller myFileName.py -w --icon myIconName.icns

EDIT: forgot to link source of solution

SeánMcK
  • 392
  • 3
  • 17