<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Yet another Could not load the Qt platform plugin &quot;cocoa&quot; even though it was found.]]></title><description><![CDATA[<p dir="auto">Hi Folks,</p>
<p dir="auto">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.</p>
<p dir="auto">My platform is:</p>
<ul>
<li>macOS 12.5.1</li>
<li>PySide6==6.3.1</li>
<li>pyinstaller==5.3</li>
</ul>
<p dir="auto">When running my program (before packaging with PyInstaller) via</p>
<pre><code>python main.py
</code></pre>
<p dir="auto">everything works great.</p>
<p dir="auto">I've created a .spec file for pyinstaller:</p>
<pre><code>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,
)


</code></pre>
<p dir="auto">then</p>
<pre><code>pyinstaller 'app_packaging.spec'
</code></pre>
<p dir="auto">When double clicking the executable 'Data Manager.app' in the list folder - it fails.<br />
When running the app executable in the app contents setting the QT_DEBUG_PLUGINS=1 i get the following:</p>
<pre><code>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'
</code></pre>
<p dir="auto">I can see that the app cannot locate the libqcocoa, but the plugin is located inside the app bundle:</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/53f8c7e4-62f0-4148-8df1-6bc6967b262e.jpg" alt="Screenshot 2022-09-12 at 11.05.19.jpg" class=" img-fluid img-markdown" /></p>
<p dir="auto">Could someone please help!</p>
]]></description><link>https://forum.qt.io/topic/139247/yet-another-could-not-load-the-qt-platform-plugin-cocoa-even-though-it-was-found</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 05:32:01 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139247.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 12 Sep 2022 08:07:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Yet another Could not load the Qt platform plugin &quot;cocoa&quot; even though it was found. on Mon, 12 Sep 2022 20:11:52 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">The paths in the bundle do not look quite right.</p>
<p dir="auto">Did you already saw this <a href="https://www.pythonguis.com/tutorials/packaging-pyside6-applications-pyinstaller-macos-dmg/" target="_blank" rel="noopener noreferrer nofollow ugc">tutorial</a> ?</p>
]]></description><link>https://forum.qt.io/post/728438</link><guid isPermaLink="true">https://forum.qt.io/post/728438</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 12 Sep 2022 20:11:52 GMT</pubDate></item></channel></rss>