1

Compiling a .py file that requires pillow to .app with py2app works, but it raises:

Modules not found (conditional imports):
 * Image (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/py2app/recipes/PIL/prescript.py)

Then, when I try to start the app, it stops immediately and shows this:

Last login: Fri Jul  3 19:06:46 on ttys001
/Users/Cedric/Desktop/Avatar\ Resourcepack\ Generator\ \(Mac\)/dist/Avatar\ Resourcepack\ Creator.app/Contents/MacOS/Avatar\ Resourcepack\ Creator ; exit;
macbook-air-jpc:~ Cedric$ /Users/Cedric/Desktop/Avatar\ Resourcepack\ Generator\ \(Mac\)/dist/Avatar\ Resourcepack\ Creator.app/Contents/MacOS/Avatar\ Resourcepack\ Creator ; exit;
Traceback (most recent call last):
  File "/Users/Cedric/Desktop/Avatar Resourcepack Generator (Mac)/dist/Avatar Resourcepack Creator.app/Contents/Resources/__boot__.py", line 89, in _recipes_pil_prescript
    import Image
ModuleNotFoundError: No module named 'Image'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/Cedric/Desktop/Avatar Resourcepack Generator (Mac)/dist/Avatar Resourcepack Creator.app/Contents/Resources/__boot__.py", line 136, in <module>
    _recipes_pil_prescript(['GbrImagePlugin', 'MicImagePlugin', 'PalmImagePlugin', 'XpmImagePlugin', 'TgaImagePlugin', 'DcxImagePlugin', 'PsdImagePlugin', 'SgiImagePlugin', 'EpsImagePlugin', 'XbmImagePlugin', 'BlpImagePlugin', 'PixarImagePlugin', 'FliImagePlugin', 'DdsImagePlugin', 'GribStubImagePlugin', 'XVThumbImagePlugin', 'PngImagePlugin', 'GifImagePlugin', 'Jpeg2KImagePlugin', 'IptcImagePlugin', 'IcnsImagePlugin', 'BmpImagePlugin', 'MpoImagePlugin', 'PpmImagePlugin', 'BufrStubImagePlugin', 'FtexImagePlugin', 'WebPImagePlugin', 'TiffImagePlugin', 'MpegImagePlugin', 'MspImagePlugin', 'SpiderImagePlugin', 'ImImagePlugin', 'FpxImagePlugin', 'SunImagePlugin', 'Hdf5StubImagePlugin', 'CurImagePlugin', 'McIdasImagePlugin', 'PdfImagePlugin', 'FitsStubImagePlugin', 'WmfImagePlugin', 'PcxImagePlugin', 'IcoImagePlugin', 'ImtImagePlugin', 'JpegImagePlugin', 'PcdImagePlugin'])
  File "/Users/Cedric/Desktop/Avatar Resourcepack Generator (Mac)/dist/Avatar Resourcepack Creator.app/Contents/Resources/__boot__.py", line 93, in _recipes_pil_prescript
    from PIL import Image
  File "<frozen zipimport>", line 259, in load_module
  File "PIL/Image.pyc", line 94, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "PIL/_imaging.pyc", line 14, in <module>
  File "PIL/_imaging.pyc", line 10, in __load
  File "imp.pyc", line 342, in load_dynamic
ImportError: dlopen(/Users/Cedric/Desktop/Avatar Resourcepack Generator (Mac)/dist/Avatar Resourcepack Creator.app/Contents/Resources/lib/python3.8/lib-dynload/PIL/_imaging.so, 2): Library not loaded: @loader_path/.dylibs/libjpeg.9.dylib
  Referenced from: /Users/Cedric/Desktop/Avatar Resourcepack Generator (Mac)/dist/Avatar Resourcepack Creator.app/Contents/Resources/lib/python3.8/lib-dynload/PIL/_imaging.so
  Reason: image not found
2020-07-03 19:09:41.090 Avatar Resourcepack Creator[3073:100237] Avatar Resourcepack Creator Error
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

The issue seems to be that it doesn't find the Pillow module and can't import the Image module either. Here is my setup file:

from setuptools import setup

APP = ['Avatar Resourcepack Creator.py']
DATA_FILES = ["assets", "icons", "logs", "pack.mcmeta", "pack.png", "Sorts utilisés.txt"]
OPTIONS = {}

setup(
    app=APP,
    data_files=DATA_FILES,
    options=dict(py2app=dict(iconfile='icons/icon.ico', includes="tkinter, PIL, zipfile, os, getpass")),
    setup_requires=['py2app'],
    install_requires=['pillow'],
)

This has been driving me mad, as I've searched everywhere on the internet but didn't find anything. Please help!

Vynokris
  • 31
  • 1
  • 6
  • Appears to be a duplicate of https://stackoverflow.com/questions/53690402/py2app-pil-image-error-when-launching-app. Did any of the suggestions in that thread help you? – Stuart Berg Jul 23 '20 at 20:33
  • You may also find this question helpful: https://stackoverflow.com/questions/62141863/py2app-placing-pil-dylibs-in-zip-file/62164220#62164220 – Stuart Berg Jul 23 '20 at 20:35

0 Answers0