ronaldoussoren / py2app

py2app is a Python setuptools command which will allow you to make standalone Mac OS X application bundles and plugins from Python scripts.
Other
352 stars 35 forks source link

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

Closed ronaldoussoren closed 3 years ago

ronaldoussoren commented 9 years ago

Original report by andrew smart (Bitbucket: pappaloo, GitHub: pappaloo).


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

ronaldoussoren commented 3 years ago

Fixed in c9fcb5e41da33a5ce8a60c71b438506d33ce9451.