Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

This application failed to start because no Qt platform plugin could be initialized



  • I read several posts about this topic here and in other websites, but most were about the older versions of QT. I tried to apply them but whit no results. I also tried to reinstall QT and to update whatever I can update.

    The full message I receive is the following:

    =========

    (base) ProOne:Dashboard adrianosavi$ export QT_DEBUG_PLUGINS=1(base) ProOne:Dashboard adrianosavi$ /Users/adrianosavi/opt/anaconda3/bin/python "/Users/adrianosavi/OneDrive/Offline Files/Savio Shandong/IT/Dashboard/test.py"
    QFactoryLoader::QFactoryLoader() checking directory path "/Users/adrianosavi/opt/anaconda3/plugins/platforms" ...
    QFactoryLoader::QFactoryLoader() looking at "/Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib"
    Found metadata in lib /Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib, metadata=
    {
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
    "Keys": [
    "cocoa"
    ]
    },
    "className": "QCocoaIntegrationPlugin",
    "debug": false,
    "version": 329991
    }

    Got keys from plugin meta data ("cocoa")
    QFactoryLoader::QFactoryLoader() looking at "/Users/adrianosavi/opt/anaconda3/plugins/platforms/libqminimal.dylib"
    Found metadata in lib /Users/adrianosavi/opt/anaconda3/plugins/platforms/libqminimal.dylib, metadata=
    {
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
    "Keys": [
    "minimal"
    ]
    },
    "className": "QMinimalIntegrationPlugin",
    "debug": false,
    "version": 329991
    }

    Got keys from plugin meta data ("minimal")
    QFactoryLoader::QFactoryLoader() looking at "/Users/adrianosavi/opt/anaconda3/plugins/platforms/libqoffscreen.dylib"
    Found metadata in lib /Users/adrianosavi/opt/anaconda3/plugins/platforms/libqoffscreen.dylib, metadata=
    {
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
    "Keys": [
    "offscreen"
    ]
    },
    "className": "QOffscreenIntegrationPlugin",
    "debug": false,
    "version": 329991
    }

    Got keys from plugin meta data ("offscreen")
    QFactoryLoader::QFactoryLoader() checking directory path "/Users/adrianosavi/opt/anaconda3/bin/platforms" ...
    Cannot load library /Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib: (dlopen(/Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib, 133): Library not loaded: @rpath/libQt5PrintSupport.5.dylib
    Referenced from: /Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib
    Reason: image not found)
    QLibraryPrivate::loadPlugin failed on "/Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib" : "Cannot load library /Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib: (dlopen(/Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib, 133): Library not loaded: @rpath/libQt5PrintSupport.5.dylib\n Referenced from: /Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib\n Reason: image not found)"
    qt.qpa.plugin: Could not load the Qt platform plugin "cocoa" in "" 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, minimal, offscreen.

    Abort trap: 6

    ====================

    I hope I can receive support for this issue.


  • Qt Champions 2019

    @adsavi Check why libQt5PrintSupport.5.dylib was not loaded.
    Is it where?
    If so then where is it located?



  • @jsulm said in This application failed to start because no Qt platform plugin could be initialized:

    libQt5PrintSupport.5.dylib

    In my mac, I have /Users/adrianosavi/opt/anaconda3/lib/libQt5.archive.zip and inside this there is libQt5PrintSupport.5.dylib, this is the only place where I can find libQt5PrintSupport.5.dylib

    It seems it has not been installed. How to install it?


  • Qt Champions 2019

    @adsavi said in This application failed to start because no Qt platform plugin could be initialized:

    How to install it?

    How did you install other Qt parts?



  • @jsulm from source code qt-everywhere-src-5.15.1.tar.xz


  • Qt Champions 2019

    @adsavi You mean you built Qt by yourself?



  • @jsulm the online installer gave me an error several times so finally used the offline one.


  • Qt Champions 2019

    @adsavi Not sure what you mean. Did you now install Qt using offline installer and it works or does it not work?
    qt-everywhere-src-5.15.1.tar.xz is not offline installer but Qt source code archive.



  • @jsulm I started from that file, unzip it, configure, chose the open source option, and then sudo make and sudo make install. When I tried it gave me the error I posted here.


  • Qt Champions 2019

    @adsavi Then you should check config.log file to see whether printing support was enabled or not



  • @jsulm said in This application failed to start because no Qt platform plugin could be initialized:

    config.log

    the config.log text is:

    ====

    executing config test gypsy

    • cd /Users/adrianosavi/qtlocation/config.tests/gypsy && /Users/adrianosavi/qtbase/bin/qmake -spec /Users/adrianosavi/Downloads/qt-everywhere-src-5.15.1/qtbase/mkspecs/macx-clang "CONFIG -= qt debug_and_release app_bundle lib_bundle" /Users/adrianosavi/Downloads/qt-everywhere-src-5.15.1/qtlocation/config.tests/gypsy
    • cd /Users/adrianosavi/qtlocation/config.tests/gypsy && MAKEFLAGS= make

    /Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++11 -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.13 -fno-exceptions -Wall -Wextra -fPIC -DQT_NO_LINKED_LIST -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_LINKED_LIST -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/Users/adrianosavi/Downloads/qt-everywhere-src-5.15.1/qtlocation/config.tests/gypsy -I. -I/Users/adrianosavi/Downloads/qt-everywhere-src-5.15.1/qtbase/mkspecs/macx-clang -o .obj/main.o /Users/adrianosavi/Downloads/qt-everywhere-src-5.15.1/qtlocation/config.tests/gypsy/main.cpp
    /Users/adrianosavi/Downloads/qt-everywhere-src-5.15.1/qtlocation/config.tests/gypsy/main.cpp:29:10: fatal error: 'gypsy/gypsy-satellite.h' file not found
    #include <gypsy/gypsy-satellite.h>
    ^~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    make[1]: *** [.obj/main.o] Error 1
    test gypsy FAILED
    executing config test winrt

    • cd /Users/adrianosavi/qtlocation/config.tests/winrt && /Users/adrianosavi/qtbase/bin/qmake -spec /Users/adrianosavi/Downloads/qt-everywhere-src-5.15.1/qtbase/mkspecs/macx-clang "CONFIG -= qt debug_and_release app_bundle lib_bundle" /Users/adrianosavi/Downloads/qt-everywhere-src-5.15.1/qtlocation/config.tests/winrt
    • cd /Users/adrianosavi/qtlocation/config.tests/winrt && MAKEFLAGS= make

    /Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++11 -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.13 -fno-exceptions -Wall -Wextra -fPIC -DQT_NO_LINKED_LIST -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_LINKED_LIST -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/Users/adrianosavi/Downloads/qt-everywhere-src-5.15.1/qtlocation/config.tests/winrt -I. -I/Users/adrianosavi/Downloads/qt-everywhere-src-5.15.1/qtbase/mkspecs/macx-clang -o .obj/main.o /Users/adrianosavi/Downloads/qt-everywhere-src-5.15.1/qtlocation/config.tests/winrt/main.cpp
    /Users/adrianosavi/Downloads/qt-everywhere-src-5.15.1/qtlocation/config.tests/winrt/main.cpp:30:10: fatal error: 'windows.system.h' file not found
    #include <windows.system.h>
    ^~~~~~~~~~~~~~~~~~
    1 error generated.
    make[1]: *** [.obj/main.o] Error 1
    test winrt FAILED

    ====

    It seems the configuration failed.
    But I was able to go on with the following steps.
    What do you suggest to me?


  • Qt Champions 2019

    @adsavi said in This application failed to start because no Qt platform plugin could be initialized:

    What do you suggest to me?

    What I already suggested: check the config.log file to see whether PRINTING support was activated or not. The failed checks are related to QtLocation module and do not have anything to do with printing...



  • @jsulm I installed QT again and now I did not have any problem with the installation and the installation log shows no problem.

    There is not printing support issues but now the message I receive is this:

    ===========

    QFactoryLoader::QFactoryLoader() checking directory path "/Users/adrianosavi/opt/anaconda3/plugins/platforms" ...
    QFactoryLoader::QFactoryLoader() looking at "/Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib"
    Found metadata in lib /Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib, metadata=
    {
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
    "Keys": [
    "cocoa"
    ]
    },
    "className": "QCocoaIntegrationPlugin",
    "debug": false,
    "version": 329991
    }

    Got keys from plugin meta data ("cocoa")
    QFactoryLoader::QFactoryLoader() looking at "/Users/adrianosavi/opt/anaconda3/plugins/platforms/libqminimal.dylib"
    Found metadata in lib /Users/adrianosavi/opt/anaconda3/plugins/platforms/libqminimal.dylib, metadata=
    {
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
    "Keys": [
    "minimal"
    ]
    },
    "className": "QMinimalIntegrationPlugin",
    "debug": false,
    "version": 329991
    }

    Got keys from plugin meta data ("minimal")
    QFactoryLoader::QFactoryLoader() looking at "/Users/adrianosavi/opt/anaconda3/plugins/platforms/libqoffscreen.dylib"
    Found metadata in lib /Users/adrianosavi/opt/anaconda3/plugins/platforms/libqoffscreen.dylib, metadata=
    {
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
    "Keys": [
    "offscreen"
    ]
    },
    "className": "QOffscreenIntegrationPlugin",
    "debug": false,
    "version": 329991
    }

    Got keys from plugin meta data ("offscreen")
    QFactoryLoader::QFactoryLoader() checking directory path "/Users/adrianosavi/opt/anaconda3/bin/platforms" ...
    Cannot load library /Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib: (dlopen(/Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib, 133): Library not loaded: @rpath/libQt5PrintSupport.5.dylib
    Referenced from: /Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib
    Reason: image not found)
    QLibraryPrivate::loadPlugin failed on "/Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib" : "Cannot load library /Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib: (dlopen(/Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib, 133): Library not loaded: @rpath/libQt5PrintSupport.5.dylib\n Referenced from: /Users/adrianosavi/opt/anaconda3/plugins/platforms/libqcocoa.dylib\n Reason: image not found)"
    qt.qpa.plugin: Could not load the Qt platform plugin "cocoa" in "" 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, minimal, offscreen.

    Abort trap: 6

    =====

    What is the next step you suggest?


  • Qt Champions 2019

    @adsavi It can't load libqcocoa.dylib because it seems to depend on libQt5PrintSupport.5.dylib which it can't find for some reason.
    I don't know why this happens (not a Mac user).
    What Qt version did you install and how?



  • @jsulm the version is Qt version 5.15.1 - Just installed today.
    I found I have this file: /Users/adrianosavi/opt/anaconda3/lib/libQt5.archive/libQt5PrintSupport.5.9.7.dylib but I do not know fi there is any connection.


  • Qt Champions 2019

    @adsavi said in This application failed to start because no Qt platform plugin could be initialized:

    installed today

    How? Using online installer? Does it have libQt5PrintSupport.*.dylib?
    libQt5PrintSupport.5.9.7.dylib - this is a different version



  • @jsulm installed with an online installer. In my computer, there are no other dylib files beginning with libQt5PrintSupport.


  • Qt Champions 2019

    @adsavi said in This application failed to start because no Qt platform plugin could be initialized:

    there are no other dylib files beginning with libQt5PrintSupport

    This is strange, it should be there.
    Maybe somebody else knows, I'm not a Mac user.



  • @jsulm is there any way to know to which module of Qt this library belongs so that I can use the maintenance tool to try to reinstall again?


  • Lifetime Qt Champion

    Hi,

    There's something fishy here. It looks like your have installed Qt using conda. I suspect it came with PySide2. Is that the case ?
    Now if you used the online installer, how are you running your application ?



  • @SGaist yes I have installed Conda. I try uninstall it but no change. I run the application from visual studio code but if I run it from the terminal I got this message:

    adrianosavi@ProOne Dashboard % python test.py
    Traceback (most recent call last):
    File "test.py", line 2, in <module>
    from PySide2.QtWidgets import QApplication, QDialog, QLineEdit, QPushButton
    ImportError: No module named PySide2.QtWidgets
    adrianosavi@ProOne Dashboard % python test.py
    Traceback (most recent call last):
    File "test.py", line 2, in <module>
    from PySide2 import QtWidgets #import QApplication, QDialog, QLineEdit, QPushButton
    ImportError: No module named PySide2
    adrianosavi@ProOne Dashboard % pip install PySide2
    Requirement already satisfied: PySide2 in /Users/adrianosavi/opt/anaconda3/lib/python3.8/site-packages (5.15.1)
    Requirement already satisfied: shiboken2==5.15.1 in /Users/adrianosavi/opt/anaconda3/lib/python3.8/site-packages (from PySide2) (5.15.1)


  • Lifetime Qt Champion

    Looks like you installed all your stuff in the base conda environment which is a bad idea.

    I would recommend re-install conda cleanly and create a proper environment to install PySide2.