How to solve libpython3.9.dylib image not found error on MacOS Python app build with pyinstaller?

Viewed 218

I am building a game using pyinstaller on MacOS BigSur. It builds properly, but is failing with a "libpython3.9.dylib" "image not found" error (complete error below)

After pyinstaller builds the app, I'm running it with: dist/gralli_quest.app/Contents/MacOS/gralli_quest

Here's the output with debugging enabled:

    [22699] PyInstaller Bootloader 3.x
    [22699] LOADER: executable is /Users/bernard/projects/gralli_quest/dist/gralli_quest.app/Contents/MacOS/gralli_quest
    [22699] LOADER: homepath is /Users/bernard/projects/gralli_quest/dist/gralli_quest.app/Contents/MacOS
    [22699] LOADER: _MEIPASS2 is NULL
    [22699] LOADER: archivename is /Users/bernard/projects/gralli_quest/dist/gralli_quest.app/Contents/MacOS/gralli_quest
    [22699] LOADER: Cookie found at offset 0x17CD99D2
    [22699] LOADER: Extracting binaries
    [22699] LOADER: Executing self as child
    [22699] LOADER: set _MEIPASS2 to /var/folders/m7/322j4l357l3chdczl5j75phw0000gn/T/_MEIlAeO5C
    [22699] LOADER: Registering signal handlers
    [22704] PyInstaller Bootloader 3.x
    [22704] LOADER: executable is /Users/bernard/projects/gralli_quest/dist/gralli_quest.app/Contents/MacOS/gralli_quest
    [22704] LOADER: homepath is /Users/bernard/projects/gralli_quest/dist/gralli_quest.app/Contents/MacOS
    [22704] LOADER: _MEIPASS2 is /var/folders/m7/322j4l357l3chdczl5j75phw0000gn/T/_MEIlAeO5C
    [22704] LOADER: archivename is /Users/bernard/projects/gralli_quest/dist/gralli_quest.app/Contents/MacOS/gralli_quest
    [22704] LOADER: Cookie found at offset 0x17CD99D2
    [22704] LOADER: Already in the child - running user`s code.
    [22704] LOADER: Python library: /var/folders/m7/322j4l357l3chdczl5j75phw0000gn/T/_MEIlAeO5C/libpython3.9.dylib
    [22704] Error loading Python lib `/var/folders/m7/322j4l357l3chdczl5j75phw0000gn/T/_MEIlAeO5C/libpython3.9.dylib`: dlopen: dlopen(/var/folders/m7/322j4l357l3chdczl5j75phw0000gn/T/_MEIlAeO5C/libpython3.9.dylib, 10): image not found
    [22699] LOADER: Restoring signal handlers
    [22699] LOADER: freeing args
    [22699] LOADER: returning child exit status 255
    [22699] LOADER: Back to parent (RC: 255)
    [22699] LOADER: Doing cleanup
    [22699] LOADER: Freeing archive status for /Users/bernard/projects/gralli_quest/dist/gralli_quest.app/Contents/MacOS/gralli_quest

The file libpython3.9.dylib does exist within the .app folder created by pyinstaller:

ls -al dist/gralli_quest.app/Contents/MacOS/libpython3.9.dylib
-rwxr-xr-x  1 bernard  staff  3831440 Dec 16 17:20 dist/gralli_quest.app/Contents/MacOS/libpython3.9.dylib

Things I've tried:

  • Googling various variations of the error message (suprisingly little came up)
  • reading the pyinstaller t-shooting docs
  • rebuilding Python with both --enable-shared and --enable-framework options. (env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.9.9)
  • trying a few versions of Python - 3.9.6, 3.9.8, and 3.9.9
  • creating brand new virtual envs
  • moving the gralli_quest.app folder outside the directory with my pyenv configured and running it from there
  • enabling debugging in my pyinstaller .spec file
  • brew update && brew upgrade
  • upgrading all my pip packages to the latest versions (not that this was likely to solve it)

Can provide my .spec file or any other info that would help.

0 Answers
Related