【问题标题】:Py2App PIL Image error when launching app启动应用程序时 Py2App PIL Image 错误
【发布时间】:2019-05-10 10:50:58
【问题描述】:

我正在使用 py2app 将 python 文件转换为应用程序并遇到此错误:

Traceback (most recent call last):
  File "/Users/MYUSER/PycharmProjects/webstuff/BotTest/dist/ws1.app/Contents/Resources/__boot__.py", line 87, 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/MYUSER/PycharmProjects/webstuff/BotTest/dist/ws1.app/Contents/Resources/__boot__.py", line 132, in <module>
    _recipes_pil_prescript(['ImtImagePlugin', 'XpmImagePlugin', 'FtexImagePlugin', 'McIdasImagePlugin', 'MpegImagePlugin', 'SpiderImagePlugin', 'DdsImagePlugin', 'FpxImagePlugin', 'MspImagePlugin', 'XVThumbImagePlugin', 'GbrImagePlugin', 'MpoImagePlugin', 'BmpImagePlugin', 'BlpImagePlugin', 'IptcImagePlugin', 'PpmImagePlugin', 'JpegImagePlugin', 'SgiImagePlugin', 'PalmImagePlugin', 'PsdImagePlugin', 'ImImagePlugin', 'MicImagePlugin', 'BufrStubImagePlugin', 'WebPImagePlugin', 'FliImagePlugin', 'TgaImagePlugin', 'PixarImagePlugin', 'TiffImagePlugin', 'CurImagePlugin', 'PngImagePlugin', 'FitsStubImagePlugin', 'Hdf5StubImagePlugin', 'DcxImagePlugin', 'IcnsImagePlugin', 'EpsImagePlugin', 'GifImagePlugin', 'SunImagePlugin', 'WmfImagePlugin', 'GribStubImagePlugin', 'PcdImagePlugin', 'IcoImagePlugin', 'XbmImagePlugin', 'PdfImagePlugin', 'PcxImagePlugin', 'Jpeg2KImagePlugin'])
  File "/Users/MYUSER/PycharmProjects/webstuff/BotTest/dist/ws1.app/Contents/Resources/__boot__.py", line 90, in _recipes_pil_prescript
    from PIL import Image
  File "PIL/Image.pyc", line 64, in <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/MYUSER/PycharmProjects/webstuff/BotTest/dist/ws1.app/Contents/Resources/lib/python3.7/lib-dynload/PIL/_imaging.so, 2): Library not loaded: @loader_path/.dylibs/libjpeg.9.dylib
  Referenced from: /Users/MYUSER/PycharmProjects/webstuff/BotTest/dist/ws1.app/Contents/Resources/lib/python3.7/lib-dynload/PIL/_imaging.so
  Reason: image not found

出错后,程序终止。程序中使用的所有图像都使用设置中的 data_files 包含在其中。我的代码有错误还是与 py2app 有关?

【问题讨论】:

  • 这个问题解决了吗?现在遇到同样的问题。

标签: python py2app


【解决方案1】:

在你的

python setup.py py2app

python3 setup.py py2app

包括标志--packages=PIL

【讨论】:

    【解决方案2】:

    libpeg安装动态库

    brew install libjpeg
    

    应该解决这个问题,但是我仍然遇到了其他依赖项,例如 zlibopenjpeg。但是我自己编译 Pillow 是有效的。

    git clone git@github.com:python-pillow/Pillow.git
    brew install jpeg
    brew install openjpeg
    brew install zlib
    export LDFLAGS="-L/usr/local/opt/zlib/lib"
    export CPPFLAGS="-I/usr/local/opt/zlib/include"
    cd Pillow
    python setup.py install
    

    总结如下:

    --------------------------------------------------------------------
    PIL SETUP SUMMARY
    --------------------------------------------------------------------
    version      Pillow 7.2.0.dev0
    platform     darwin 3.8.1 (v3.8.1:1b293b6006, Dec 18 2019, 14:08:53)
                 [Clang 6.0 (clang-600.0.57)]
    --------------------------------------------------------------------
    --- JPEG support available
    --- OPENJPEG (JPEG2000) support available (2.3)
    --- ZLIB (PNG/ZIP) support available
    *** LIBIMAGEQUANT support not available
    --- LIBTIFF support available
    --- FREETYPE2 support available
    --- LITTLECMS2 support available
    *** WEBP support not available
    *** WEBPMUX support not available
    --- XCB (X protocol) support available
    --------------------------------------------------------------------
    To add a missing option, make sure you have the required
    

    【讨论】:

      猜你喜欢
      • 2013-09-01
      • 2018-10-09
      • 1970-01-01
      • 2018-01-11
      • 2020-10-22
      • 1970-01-01
      • 2017-06-28
      • 2013-11-29
      • 1970-01-01
      相关资源
      最近更新 更多