noo*_*000 5 macos pyinstaller python-3.x
我已经制作了一个应用程序,现在正在 Macos 和 Windows 上分发(Windows 已成功编译),但是当我尝试编译我的应用程序时,它不断抛出错误SystemError: codesign failure! 在 pyinstaller 中,我使用--onefile标志,并且我在没有该标志的情况下尝试过它(python pyinstaller.py app.py,我无法使用python pyinstaller app.py,因为我被抛出命令未找到)。这是完整的错误消息:
326 INFO: Building PKG (CArchive) PKG-00.pkg
4245 WARNING: codesign command (['codesign', '-s', '-', '--force', '--all-architectures', '--timestamp', '/Users/admin/Library/Application Support/pyinstaller/bincache00_py39_64bit/x86_64/adhoc/no-entitlements/lib-dynload/resource.cpython-39-darwin.so']) failed with error code 1!
stdout: ''
stderr: '/Users/admin/Library/Application Support/pyinstaller/bincache00_py39_64bit/x86_64/adhoc/no-entitlements/lib-dynload/resource.cpython-39-darwin.so: invalid or unsupported format for signature\n'
Traceback (most recent call last):
File "/Users/admin/Documents/Cloud/hero/pyinstaller.py", line 17, in <module>
run()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/__main__.py", line 126, in run
run_build(pyi_config, spec_file, **vars(args))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 815, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 762, in build
exec(code, spec_namespace)
File "/Users/admin/Documents/Cloud/hero/app.spec", line 23, in <module>
exe = EXE(pyz,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/api.py", line 509, in __init__
self.pkg = PKG(self.toc, cdict=kwargs.get('cdict', None),
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/api.py", line 208, in __init__
self.__postinit__()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/datastruct.py", line 159, in __postinit__
self.assemble()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/api.py", line 274, in assemble
fnm = checkCache(fnm, strip=self.strip_binaries,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/utils.py", line 391, in checkCache
osxutils.sign_binary(cachedfile, codesign_identity, entitlements_file)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/utils/osx.py", line 383, in sign_binary
raise SystemError("codesign failure!")
SystemError: codesign failure!
Run Code Online (Sandbox Code Playgroud)
由于我从未为 mac 编译过应用程序,而且这是我第一次这样做,所以我不知道这到底意味着什么。这是使用 python 3.9。
小智 10
这似乎是 pyinstaller 执行临时签名方式的问题,因为协同签名在 4.3 之后的某个时间发生了变化(请参阅https://github.com/pyinstaller/pyinstaller/issues/6167)。基于最新的 Big Sur (MacOS 11.5.2) 构建应该可以正常工作,但我假设您使用的是 Catalina 或更早版本。
您可以:
pip uninstall pyinstaller使用和降级到 pyinstaller 4.3 pip install -Iv pyinstaller==4.3,然后按原样重建。或者
如果您想自己签署应用程序,您可以这样做:
打开Keychain Access
转到屏幕顶部的菜单并选择Keychain Access > Certificate Assistant > Create a Certificate
在出现的窗口中更改Certificate Type为Code Signing,选择Create并记下证书的名称
使用标志构建pyinstaller源,--codesign-identity <name>其中<name>是您在步骤 3 中创建的证书的名称。