Pyinstaller错误:';SystemError:MacOS上的CoDesign失败!'; [英] Pyinstaller error: 'SystemError: codesign failure!' on macOS
问题描述
我制作了一个正在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
'
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!
因为我从来没有为Mac编译过应用程序,而且这是我第一次这样做,所以我不知道这到底是什么意思。这使用的是python 3.9。
pyinstaller
这似乎是推荐答案执行临时签名的方式的问题,因为代码设计在4.3后的某个时候发生了更改(请参阅https://github.com/pyinstaller/pyinstaller/issues/6167)。在最新的Big Sur(MacOS 11.5.2)上构建应该可以正常工作,但我假设您使用的是Catalina或更早版本。
您可以:
- 使用
pip uninstall pyinstaller
和pip install -Iv pyinstaller==4.3
降级到pyinstaller 4.3,然后按原样重建。
或
- 提供证书以自己签署应用程序。
如果您想要自己签署应用程序,可以这样做:
打开
Keychain Access
转到屏幕顶部的菜单并选择
Keychain Access > Certificate Assistant > Create a Certificate
在显示的窗口中,将
Certificate Type
更改为Code Signing
,选择Create
并记下证书的名称使用
--codesign-identity <name>
标志构建pyinstaller
源,其中<name>
是您在步骤3中创建的证书的名称。
这篇关于Pyinstaller错误:';SystemError:MacOS上的CoDesign失败!';的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!