1

I've recently created a GUI application using tkinter in python. When i create the application in 'Alias mode' using:

python3 setup.py py2app -A

The application is created and everything works as intended with no issues. I did this to ensure that it would then work when creating the stand-alone version, however it doesn't. The application fails to open and, although i'm given the option to enter the Console, i have no idea how to interpret the data that is presented. Because of this i opened the app through 'package contents' and these were the errors that i received in terminal:

ImportError: dlopen(/Users/MYNAME/dist/MYAPP.app/Contents/Resources/lib/python3.8/lib-dynload/sklearn/__check_build/_check_build.so, 2): Library not loaded: @loader_path/../.dylibs/libomp.dylib
  Referenced from: /Users/MYNAME/lib/python3.8/lib-dynload/sklearn/__check_build/_check_build.so
  Reason: image not found

and:

NotADirectoryError: [Errno 20] Not a directory: '/Users/MYNAME/dist/MYAPP.app/Contents/Resources/lib/python38.zip/sklearn/__check_build'

Also, although i'm not sure it's relevant, in my setup.py file i didn't specify the selenium chromedriver that i'm using in the 'DATA_FILES' section. Should i have done this?

Here's a copy of my setup file for reference:

from setuptools import setup

APP = ['test9.py']
APP_NAME = "MYAPP"
DATA_FILES = ['logocopy.png', 'britishdict.txt']
OPTIONS = {
 'iconfile':'app_icon.icns',
 'argv_emulation': True,
 'packages': ["certifi"],
 'plist': {
        'CFBundleName': APP_NAME,
        'CFBundleDisplayName': APP_NAME,
        'CFBundleGetInfoString': "MYAPP GUI",
        'CFBundleVersion': "1.0.7",
        'CFBundleShortVersionString': "1.0.7",
        'NSHumanReadableCopyright': u"Copyright © 2020, MYNAME, All Rights Reserved"
    }
}

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

Could someone offer some insight into what the issue may be? Thanks in advance.

  • When you inspect the generated app bundle, does `libomp.dylib` appear in it anywhere? (Even in hidden directories?). If not, is it somehow getting included in the site-packages `.zip` file? I wonder if this discussion might be relevant, but I'm not sure: https://stackoverflow.com/q/62141863/162094 – Stuart Berg Jun 13 '20 at 18:13
  • As a side note, I've had luck in the past with a hacky alternative to the "correct" usage of py2app: I create a conda environment with all the app dependencies, then I create an alias app (which is merely a skeleton bundle pointing to the external environment binaries), and then I move the external environment files INTO the app bundle. You have to do a little manipulation of the links within the "alias" bundle, but then it works quite well, actually. Here are some notes on how to do that: https://gist.github.com/stuarteberg/1d36281667e4888c1d9f776168166be9 – Stuart Berg Jun 13 '20 at 18:21

0 Answers0