Pyinstaller出现错误(“加载Python时出错…未找到合适的图像”)

2024-09-28 05:23:35 发布

您现在位置: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应用程序。我怎样才能解决这个问题


Tags: no可执行文件maclibdistdownloads错误error
3条回答

我找到了让它工作的方法。Python库位于dist文件夹中后,运行:

codesign -f -s - Python

然后运行应用程序

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

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

在发布应用程序之前,您可能希望用正确的签名替换临时签名

我用以下方法解决了相同的问题:

  1. pip3 uninstall pyinstaller
  2. brew reinstall python
  3. brew install pyinstaller

请注意,在macOS上,python3.7.7或+和python3.8.3或+给出了相同的错误,因为添加了python的完全公证签名,以避免网守警报

只需安装Python3.7.6或Python3.8.2即可

相关问题 更多 >

    热门问题