python - 启动应用程序时 Py2App PIL Image 错误
问题描述
我正在使用 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 setup.py py2app
或者
python3 setup.py py2app
包括标志--packages=PIL
推荐阅读
- html - 当滚动到达页面的某个点时,使用其他内容进行位置固定的 div 滚动
- javascript - React 对选中的复选框项目的价格进行汇总
- java - 如何使用 IKVM.NET 将 .JAR 文件转换为 .dll 文件?
- reactjs - React 测试库 - userEvent 上传到输入:“找不到 toLowerCase”
- android - AccountManager 退回华为帐号,即使帐号已注销
- javascript - 从承诺中提取价值
- sql - 如何在 BigQuery SQL 中混合使用 IF 和 CASE
- android - 使用 In-App Promo SDK 建议快捷方式
- python - 如何在 Django 中一次更新所有记录
- docker - 如何使用 nsenter 实用程序从容器连接主机