Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Yet another Could not load the Qt platform plugin "cocoa" even though it was found.
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.

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DanilZ
    wrote on last edited by DanilZ
    #1

    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.py
    

    everything 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:

    Screenshot 2022-09-12 at 11.05.19.jpg

    Could someone please help!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      The paths in the bundle do not look quite right.

      Did you already saw this tutorial ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt
      • Unsolved