Samuel Dana
Samuel Dana

Reputation: 15

Py2App error when lauching app (python)(MacOS)

I'm trying to convert my tkinter Python app into a native macOS application. Here's my setup.py file:

from setuptools import setup
import glob

APP = ['mail.py']
DATA_FILES = [
    ('.', ['token.json', 'email_map.json']),
    ('juillet', glob.glob('juillet/*'))
]
OPTIONS = {
    'argv_emulation': True,
    'packages': [
        'google_auth_oauthlib',  # Include Google Auth libraries
        'googleapiclient',       # Include Google API client libraries
        'PIL',                   # Include PIL (Pillow) package
        'pytesseract',           # Include pytesseract package
        'tkinter',               # Include tkinter package
    ],
    'includes': [
        'email',                 # Include email module
    ],
    'frameworks': ['/opt/homebrew/opt/libffi/lib/libffi.dylib'],  # Specify the full path to libffi.dylib
}

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

When I execute python setup.py py2app in my terminal, it completes successfully! However, when I try to open the application by navigating to dist/mail.app/Contents/MacOS/mail and executing it, I encounter the following error:

Traceback (most recent call last):
  File "/Users/samuel/Desktop/app/dist/mail.app/Contents/Resources/__boot__.py", line 30, in <module>
    import ctypes
  File "<frozen zipimport>", line 259, in load_module
  File "ctypes/__init__.pyc", line 8, in <module>
ImportError: dlopen(/Users/samuel/Desktop/app/dist/mail.app/Contents/Resources/lib/python3.9/lib-dynload/_ctypes.so, 0x0002): Library not loaded: @rpath/libffi.7.dylib
  Referenced from: <6395AA08-7787-3383-A01A-4D28063BDB02> /Users/samuel/Desktop/app/dist/mail.app/Contents/Resources/lib/python3.9/lib-dynload/_ctypes.so
  Reason: tried: '/Users/samuel/Desktop/app/dist/mail.app/Contents/Resources/lib/python3.9/lib-dynload/../../libffi.7.dylib' (no such file), '/Users/samuel/Desktop/app/dist/mail.app/Contents/Resources/lib/python3.9/lib-dynload/../../libffi.7.dylib' (no such file), '/Users/samuel/Desktop/app/dist/mail.app/Contents/Frameworks/libffi.7.dylib' (no such file), '/Users/samuel/Desktop/app/dist/mail.app/Contents/Frameworks/libffi.7.dylib' (no such file), '/usr/local/lib/libffi.7.dylib' (no such file), '/usr/lib/libffi.7.dylib' (no such file, not in dyld cache)
2024-07-06 02:39:31.386 mail[76636:40307370] Launch error
2024-07-06 02:39:31.386 mail[76636:40307370] Launch error
See the py2app website for debugging launch issues

This is my first experience with py2app and I've spent several hours on it. I really need your help. Sincerely,

Upvotes: 0

Views: 80

Answers (0)

Related Questions