首页 > 解决方案 > Pyinstaller 给出错误(“加载 Python 时出错......找不到合适的图像”)

问题描述

我在 Mac 上遇到了 pyinstaller 的问题,当我单击创建的可执行文件时会出现此错误:

[9888] Error loading Python lib '/Users/Faris/Downloads/as5/dist/startscreen/Python': dlopen: dlopen(/Users/Faris/Downloads/as5/dist/startscreen/Python, 10): no suitable image found.  Did find:
    /Users/Faris/Downloads/as5/dist/startscreen/Python: code signature invalid for '/Users/Faris/Downloads/as5/dist/startscreen/Python'

这是一个使用 PIL 和 4 个 PNG 文件的 GUI 应用程序。我怎样才能解决这个问题?

标签: pythonpython-imaging-librarypyinstaller

解决方案


我找到了如何让它工作。在 Python 库位于您的 dist 文件夹后,运行:

codesign -f -s - Python

然后运行应用程序。

我有一个理论问题是什么,但我不确定。我认为 Python lib 已签名,但是当 PyInstaller 将其从原来的位置移动时,签名验证失败。

该命令的作用是将签名替换为ad-hoc签名,这允许您在本地运行应用程序,但可能不算作分发的签名。我不能说我完全理解它。

在发布应用程序之前,您可能希望将临时签名替换为适当的签名。


推荐阅读