Mac 10.10.2 - This application failed to start because it could not find or load the Qt platform plugin "cocoa".



  • I am trying to develop a python app using QtGui and QtCore. I got up and running with PyQtX (64 bit pre-compiled binaries) and was able to generate a working app with py2app.

    I now need 32 bit libraries to interface with other legacy instrument drivers, so I compiled Qt 5.4.1 (just qtbase), PyQt 4.11.3 and SIP 4.16.6 in 32 bit for Mac. Everything works as expected when running my python scripts, yet when I try to generate a .app (with py2app and/or pyinstaller), I get the following error:

    This application failed to start because it could not find or load the Qt platform plugin "cocoa".

    Reinstalling the application may fix this problem.
    Abort trap: 6
    logout

    Interestingly enough, if I build the app in alias mode (python setup.py py2app -A), the Qt app starts. Once I try and build a standalone app, that is when I get the error.

    When running the binaries, I used "export DYLD_PRINT_LIBRARIES=1" to compare with/without the alias mode and found that in the alias mode, the following line appears,
    dyld: loaded: /usr/local/Qt-5.4.1/plugins/platforms/libqcocoa.dylib, and it chokes in the standalone mode with the error above about not finding the plugin "cocoa". I tried manually adding the following option to my setup.py file, which is strange to me, because this path exists on my machine whether I run in alias or standalone mode...

    'frameworks' : ['/usr/local/Qt-5.4.1/plugins/platforms/libqcocoa.dylib']

    Now in my Contents/Frameworks folder I see libqcocoa.dylib. If I run otool -L on this library, I see everything looks as expected. I also verified that every one of these dependencies is loaded in the standalone mode prior to trying to load libqcocoa.dylib.

    Any ideas? Any help greatly appreciated as this one is quite puzzling to me...

    @executable_path/../Frameworks/libqcocoa.dylib (compatibility version 0.0.0, current version 0.0.0)
    /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 21.0.0)
    /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 157.0.0)
    /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
    /usr/lib/libcups.2.dylib (compatibility version 2.0.0, current version 2.11.0)
    @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui (compatibility version 5.4.0, current version 5.4.1)
    @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore (compatibility version 5.4.0, current version 5.4.1)
    /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 48.0.0)
    /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
    @executable_path/../Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport (compatibility version 5.4.0, current version 5.4.1)
    @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.4.0, current version 5.4.1)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
    /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1343.14.0)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1151.16.0)
    /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 62.0.0)
    /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1151.16.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)


  • Any ideas? I am really stuck on this one!!!



  • Hi,
    don't know about PyQtX but for a vanilla standalone Qt app on the Mac, the Qt platform plugin usually resides in
    @executable_path/../PlugIns/platforms/libqcocoa.dylib

    Also note that the Qt plugins are not loaded using the PATH mechanism (i.e. adding a path to the .dylib isn't needed) instead Qt looks in the @executable_path/../Resources/qt.conf file for where to find libqcocoa.dylib.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.