Qt could not find the platform plugin cocoa

If you are on Mac, go to the Terminal and paste the following:

pip3 install opencv-python-headless

The Qt platform plugin requires this library to be installed.

Thanks!


I've posted the same question a few days ago on the official Qt forum, because I haven't got a response here on Stackoverflow: https://forum.qt.io/topic/98816/qt-could-not-find-the-platform-plugin-cocoa

The problem seems to be that I've installed Qt on /Library/Qt (outside of the user directory). After reinstalling Qt to /Users/ABC/Qt and a complete rebuild of my project everything seems to work now.


Try setting QT_QPA_PLATFORM_PLUGIN_PATH to the plugin directory of where you installed qt.

E.g. if QT is installed in /Users/ABC/qt, then export QT_QPA_PLATFORM_PLUGIN_PATH=/Users/ABC/qt/plugins likely fixes your problem (did it for me on my brew installed qt).

Tags:

C++

Qt