Search code examples
python-3.xtkinterpy2app.app

Py2app app not launching just asks if I want to terminate the app or open console


So I am working on a little project of mine that I want to distribute easily so naturally, I use py2app to make a single .app file that will execute on any Mac computer. I tried this tutorial: https://www.metachris.com/2015/11/create-standalone-mac-os-x-applications-with-python-and-py2app/. The problem is that even if I try the example that he gives in the tutorial it crashes and shows this window: Crash image if I look in the console log of the event I see these tow errors.

error 17:12:44.313837 +0100 Sandwich Unable to load Info.plist exceptions (eGPUOverrides)

error 17:12:44.472464 +0100 tccd Failed to copy signing info for 3112, responsible for file:///Users/-myname-/folder/projects/SandwichApp/dist/Sandwich.app/Contents/MacOS/Sandwich: #-67062: Error Domain=NSOSStatusErrorDomain Code=-67062 "(null)"

In case this is not enough info here is the code from the tutorial that I used:

import tkinter as tk

root = tk.Tk()
root.title("Sandwich")
tk.Button(root, text="Make me a Sandwich").pack()
tk.mainloop()

this is the setup.py:

from setuptools import setup

APP = ['Sandwich.py']
DATA_FILES = []
OPTIONS = {}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

I have tried to add this to my setup.py in the OPTIONS because I saw other people had it, but the same thing keeps happening:

'argv_emulation': True

Any idea on what is going on?

Thanks in advance :)


Solution

  • I have been facing a problem with the exact same error code (-67062) and managed to resolve it at least for my machine running Python 3.6.8 on macOS 10.14.2.

    Open the file ../Sandwich/Contents/MacOS/Sandwich and see the traceback message in Terminal. If tkinter imports are causing your issue like in my case, downgrade py2app via

    pip uninstall py2app

    and use an older version, e.g.

    pip install py2app==0.12

    and run py2app again. If you further encounter import problems of unwanted packages, e.g. pillow, you can exclude them with a workaround found here

    from setuptools import setup
    
    APP = ['Sandwich.py']
    DATA_FILES = []
    OPTIONS = {
        "excludes": ['pillow', 'Image'] # exclude unwanted dependencies
    }
    
    setup(
        app=APP,
        data_files=DATA_FILES,
        options={'py2app': OPTIONS},
        setup_requires=['py2app'],
    )
    

    Ronald Oussoren discussed debugging ImportErrors in py2app which can be found below for further reading:

    https://bitbucket.org/ronaldoussoren/py2app/issues/223/errors-on-compiling-in-py2app-i-have-all