Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found."

I have installed gqcnn, Pyrep and autolab_core. After that, I executed the code that my coworker wrote and, it ran fine on his computer.

However, I cannot run the code. The occurred error was

python3.7/site-packages/cv2/qt/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/home/bak/anaconda3/envs/pyrep/lib/python3.7/site-packages/cv2/qt/plugins/platforms/libqxcb.so"
Found metadata in lib /home/bak/anaconda3/envs/pyrep/lib/python3.7/site-packages/cv2/qt/plugins/platforms/libqxcb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "xcb"
        ]
    },
    "archreq": 0,
    "className": "QXcbIntegrationPlugin",
    "debug": false,
    "version": 331520
}


In /home/bak/anaconda3/envs/pyrep/lib/python3.7/site-packages/cv2/qt/plugins/platforms/libqxcb.so:
  Plugin uses incompatible Qt library (5.15.0) [release]
"The plugin '/home/bak/anaconda3/envs/pyrep/lib/python3.7/site-packages/cv2/qt/plugins/platforms/libqxcb.so' uses incompatible Qt library. (5.15.0) [release]" 
         not a plugin
QFactoryLoader::QFactoryLoader() checking directory path "/home/bak/anaconda3/envs/pyrep/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/home/bak/anaconda3/envs/pyrep/plugins/platforms/libqeglfs.so"
Found metadata in lib /home/bak/anaconda3/envs/pyrep/plugins/platforms/libqeglfs.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "eglfs"
        ]
    },
    "className": "QEglFSIntegrationPlugin",
    "debug": false,
    "version": 329991
}


Got keys from plugin meta data ("eglfs")
QFactoryLoader::QFactoryLoader() looking at "/home/bak/anaconda3/envs/pyrep/plugins/platforms/libqminimal.so"
Found metadata in lib /home/bak/anaconda3/envs/pyrep/plugins/platforms/libqminimal.so, 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 "/home/bak/anaconda3/envs/pyrep/plugins/platforms/libqminimalegl.so"
Found metadata in lib /home/bak/anaconda3/envs/pyrep/plugins/platforms/libqminimalegl.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "minimalegl"
        ]
    },
    "className": "QMinimalEglIntegrationPlugin",
    "debug": false,
    "version": 329991
}


Got keys from plugin meta data ("minimalegl")
QFactoryLoader::QFactoryLoader() looking at "/home/bak/anaconda3/envs/pyrep/plugins/platforms/libqoffscreen.so"
Found metadata in lib /home/bak/anaconda3/envs/pyrep/plugins/platforms/libqoffscreen.so, 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() looking at "/home/bak/anaconda3/envs/pyrep/plugins/platforms/libqvnc.so"
Found metadata in lib /home/bak/anaconda3/envs/pyrep/plugins/platforms/libqvnc.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "vnc"
        ]
    },
    "className": "QVncIntegrationPlugin",
    "debug": false,
    "version": 329991
}


Got keys from plugin meta data ("vnc")
QFactoryLoader::QFactoryLoader() looking at "/home/bak/anaconda3/envs/pyrep/plugins/platforms/libqxcb.so"
Found metadata in lib /home/bak/anaconda3/envs/pyrep/plugins/platforms/libqxcb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "xcb"
        ]
    },
    "className": "QXcbIntegrationPlugin",
    "debug": false,
    "version": 329991
}


Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/home/bak/anaconda3/envs/pyrep/bin/platforms" ...
Cannot load library /home/bak/anaconda3/envs/pyrep/plugins/platforms/libqxcb.so: (/home/bak/anaconda3/envs/pyrep/plugins/platforms/../../lib/libQt5XcbQpa.so.5: symbol _ZN11QFontEngine14bitmapForGlyphEj6QFixedRK10QTransform version Qt_5_PRIVATE_API not defined in file libQt5Gui.so.5 with link time reference)
QLibraryPrivate::loadPlugin failed on "/home/bak/anaconda3/envs/pyrep/plugins/platforms/libqxcb.so" : "Cannot load library /home/bak/anaconda3/envs/pyrep/plugins/platforms/libqxcb.so: (/home/bak/anaconda3/envs/pyrep/plugins/platforms/../../lib/libQt5XcbQpa.so.5: symbol _ZN11QFontEngine14bitmapForGlyphEj6QFixedRK10QTransform version Qt_5_PRIVATE_API not defined in file libQt5Gui.so.5 with link time reference)"
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/bak/anaconda3/envs/pyrep/lib/python3.7/site-packages/cv2/qt/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: eglfs, minimal, minimalegl, offscreen, vnc, xcb.

If you want to see the full error in detail, please see here. '/pyrep/' in above is my anaconda environment name.

It seems to be caused by qt. But I cannot fix this problem.

What should I do to solve this problem?

like image 972
Bak Seongho Avatar asked Sep 10 '20 12:09

Bak Seongho


People also ask

Can't find or load the Qt platform plugin XCB Ubuntu?

This application failed to start because it could not find or load the Qt platform plugin "xcb". Reinstalling the application may fix this problem. appears when you try to launch VNL, fix it by running apt-get install libx11-xcb1. This error typically appears on (K)Ubuntu version 10.10 or older.

What is XCB plugin?

On Linux, the xcb QPA (Qt Platform Abstraction) platform plugin is used. It provides the basic functionality needed by Qt GUI and Qt Widgets to run against X11.

How do I install Qt plugins?

Note: You can install only plugins that are supported by your Qt Creator version. To install plugins: Select Help > About Plugins > Install Plugins. In the Source dialog, enter the path to the archive or library that contains the plugin.


3 Answers

This issue occurs when you use opencv with pyqt5. It looks like qt plugin internally used by opencv is not compatible with pyqt5. Just unset environment variable QT_QPA_PLATFORM_PLUGIN_PATH after import cv2 statement.

import os

os.environ.pop("QT_QPA_PLATFORM_PLUGIN_PATH")

You could also update the platform plugin path after importing opencv

import os

os.environ.update({"QT_QPA_PLATFORM_PLUGIN_PATH": "/home/udara/anaconda3/envs/research-headless/lib/python3.8/site-packages/PyQt5/Qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so"})

Note that this will make opencv window functions unusable. If you want to use them, you have to build opencv from source without the qt plugin. You could build the opencv with gtk plugin instead of qt.

References https://forum.qt.io/post/654289

like image 197
UdaraWanasinghe Avatar answered Oct 11 '22 18:10

UdaraWanasinghe


This may be related to a similar error message.

I just came across this problem, in Ubuntu 20.04, Python 3.8, while trying to use matplotlib_backend_qtquick.

This answer in the mentioned thread solved it for me: https://askubuntu.com/a/1069502

like image 3
shredEngineer Avatar answered Oct 11 '22 18:10

shredEngineer


Finally, I find the solution! https://github.com/stepjam/PyRep/issues/76

The problem was loading Qt in the conda environment.

When I typed qmake -version, the terminal window showed me the qt in anaconda. After I followed the first answer at the above URL, I can fix the problem.

like image 3
Bak Seongho Avatar answered Oct 11 '22 20:10

Bak Seongho