Qt 6.12 LTS is out! See what's new in the release
blog
Yet another Could not load the Qt platform plugin "cocoa" even though it was found.
-
Hi Folks,
I've read all the corresponding threads and tried what had been described there, but still I am not able to launch my application after having packaged it with PyInstaller.
My platform is:
- macOS 12.5.1
- PySide6==6.3.1
- pyinstaller==5.3
When running my program (before packaging with PyInstaller) via
python main.pyeverything works great.
I've created a .spec file for pyinstaller:
block_cipher = None a = Analysis( ['main.py'], pathex=[], binaries=[], datas=[('ui_files', 'ui_files'), ('ExampleDatabase.csv', '.'), ('icons_rc.py', '.')], hiddenimports=[], hookspath=[], hooksconfig={}, runtime_hooks=[], excludes=[], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=block_cipher, noarchive=False, ) pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) exe = EXE( pyz, a.scripts, [], exclude_binaries=True, name='Data Manager', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, console=False, disable_windowed_traceback=False, argv_emulation=False, target_arch=None, codesign_identity=None, entitlements_file=None, ) coll = COLLECT( exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=True, upx_exclude=[], name='Data Manager', ) app = BUNDLE( coll, name='Data Manager.app', icon='app_icon.icns', bundle_identifier=None, )then
pyinstaller 'app_packaging.spec'When double clicking the executable 'Data Manager.app' in the list folder - it fails.
When running the app executable in the app contents setting the QT_DEBUG_PLUGINS=1 i get the following:qt.core.plugin.factoryloader: checking directory path "/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms" ... qt.core.plugin.factoryloader: looking at "/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms/libqcocoa.dylib" qt.core.plugin.loader: Failed to find metadata in lib /Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms/libqcocoa.dylib: '/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms/libqcocoa.dylib' is not a valid Mach-O binary (.qtmetadata section has incorrect magic) qt.core.plugin.factoryloader: "Failed to extract plugin meta data from '/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms/libqcocoa.dylib': '/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms/libqcocoa.dylib' is not a valid Mach-O binary (.qtmetadata section has incorrect magic)" not a plugin qt.core.plugin.factoryloader: looking at "/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms/libqminimal.dylib" qt.core.plugin.loader: Failed to find metadata in lib /Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms/libqminimal.dylib: '/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms/libqminimal.dylib' is not a valid Mach-O binary (.qtmetadata section has incorrect magic) qt.core.plugin.factoryloader: "Failed to extract plugin meta data from '/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms/libqminimal.dylib': '/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms/libqminimal.dylib' is not a valid Mach-O binary (.qtmetadata section has incorrect magic)" not a plugin qt.core.plugin.factoryloader: looking at "/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms/libqoffscreen.dylib" qt.core.plugin.loader: Failed to find metadata in lib /Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms/libqoffscreen.dylib: '/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms/libqoffscreen.dylib' is not a valid Mach-O binary (.qtmetadata section has incorrect magic) qt.core.plugin.factoryloader: "Failed to extract plugin meta data from '/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms/libqoffscreen.dylib': '/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/PySide6/Qt/plugins/platforms/libqoffscreen.dylib' is not a valid Mach-O binary (.qtmetadata section has incorrect magic)" not a plugin qt.core.plugin.factoryloader: checking directory path "/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/platforms" ... qt.core.plugin.factoryloader: checking directory path "/Users/danil/Qt/6.3.1/macos/plugins" ... qt.core.plugin.factoryloader: looking at "/Users/danil/Qt/6.3.1/macos/plugins/libqcocoa.dylib" qt.core.plugin.loader: Found metadata in lib /Users/danil/Qt/6.3.1/macos/plugins/libqcocoa.dylib, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "cocoa" ] }, "archlevel": 2, "className": "QCocoaIntegrationPlugin", "debug": false, "version": 393984 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("cocoa") qt.core.library: "/Users/danil/Qt/6.3.1/macos/plugins/libqcocoa.dylib" cannot load: Cannot load library /Users/danil/Qt/6.3.1/macos/plugins/libqcocoa.dylib: (dlopen(/Users/danil/Qt/6.3.1/macos/plugins/libqcocoa.dylib, 0x0085): Library not loaded: '@rpath/QtGui.framework/Versions/A/QtGui' Referenced from: '/Users/danil/Qt/6.3.1/macos/plugins/libqcocoa.dylib' Reason: tried: '/Users/danil/Qt/6.3.1/macos/plugins/../../lib/QtGui.framework/Versions/A/QtGui' (no such file), '/Users/danil/Qt/6.3.1/macos/plugins/../../lib/QtGui.framework/Versions/A/QtGui' (no such file), '/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/../../../QtGui.framework/Versions/A/QtGui' (no such file), '/Library/Frameworks/QtGui.framework/Versions/A/QtGui' (no such file), '/System/Library/Frameworks/QtGui.framework/Versions/A/QtGui' (no such file)) qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/Users/danil/Qt/6.3.1/macos/plugins/libqcocoa.dylib" : "Cannot load library /Users/danil/Qt/6.3.1/macos/plugins/libqcocoa.dylib: (dlopen(/Users/danil/Qt/6.3.1/macos/plugins/libqcocoa.dylib, 0x0085): Library not loaded: '@rpath/QtGui.framework/Versions/A/QtGui'\n Referenced from: '/Users/danil/Qt/6.3.1/macos/plugins/libqcocoa.dylib'\n Reason: tried: '/Users/danil/Qt/6.3.1/macos/plugins/../../lib/QtGui.framework/Versions/A/QtGui' (no such file), '/Users/danil/Qt/6.3.1/macos/plugins/../../lib/QtGui.framework/Versions/A/QtGui' (no such file), '/Users/danil/Desktop/pyside_study/Data_Manager/dist/Data Manager.app/Contents/MacOS/../../../QtGui.framework/Versions/A/QtGui' (no such file), '/Library/Frameworks/QtGui.framework/Versions/A/QtGui' (no such file), '/System/Library/Frameworks/QtGui.framework/Versions/A/QtGui' (no such file))" qt.qpa.plugin: Could not load the Qt platform plugin "cocoa" in "/Users/danil/Qt/6.3.1/macos/plugins" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: cocoa. [1] 5042 abort ./'Data Manager'I can see that the app cannot locate the libqcocoa, but the plugin is located inside the app bundle:

Could someone please help!