opencv qt.qpa.plugin:无法载入“”中的Qt平台插件“xcb”,即使已找到,

xxhby3vn  于 2022-11-15  发布在  其他
关注(0)|答案(6)|浏览(384)

我已经安装了gqcnn,Pyrep和autolab_core。之后,我执行了我同事写的代码,它在他的计算机上运行良好。
但是,我无法运行代码。发生的错误是

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.

如果您想详细查看完整的错误,请参阅here。上面的“/pyrep/”是我的anaconda环境名称。
好像是qt引起的,但是我修不好。
我该怎么做才能解决这个问题?

bjp0bcyl

bjp0bcyl1#

opencvpyqt5一起使用时会出现此问题看起来opencv内部使用qt插件与pyqt5不兼容只需在import cv2语句后取消设置环境变量QT_QPA_PLATFORM_PLUGIN_PATH

import os

os.environ.pop("QT_QPA_PLATFORM_PLUGIN_PATH")

您也可以在导入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"})

请注意,这将使opencv窗口函数不可用。如果您想使用它们,您必须从没有qt插件的源代码构建opencv。您可以使用gtk插件构建opencv,而不是qt
参考https://forum.qt.io/post/654289

sulc1iza

sulc1iza2#

这可能与similar error message有关。
我刚刚在Ubuntu 20.04,Python 3.8中遇到了这个问题,同时试图使用matplotlib_backend_qtquick
这个回答在提到的线索中为我解开了它:https://askubuntu.com/a/1069502

nfs0ujit

nfs0ujit3#

最后,我找到了解决方案!https://github.com/stepjam/PyRep/issues/76
问题是在conda环境中加载Qt。
当我键入qmake -version时,终端窗口显示了anaconda中的qt,在我按照上面URL的第一个答案后,我可以修复这个问题。

7kjnsjlb

7kjnsjlb4#

我想在这里补充一点。
我遇到了这个问题,但是在debian 10上,上面提到的解决方案都没有帮助。真正有帮助的是,在我的例子中,pip默认安装了pyqt 5的版本5.15.2。然而,在这里(https://repology.org/project/python:pyqt5/versions),它声明推荐debian 10使用的pyqt 5版本是5.11.3。
当我用该版本重新安装pyqt 5时:
$pip3安装PyQt 5 ==5.11.3
问题已修复。关键是,检查以下内容可能是个好主意:

  • pip默认安装pyqt 5的哪个版本
  • 哪个版本的pyqt 5是推荐的操作系统/发行版
uyto3xhc

uyto3xhc5#

如果您在没有显示/图形输出的机器(例如服务器)上运行此脚本,请确保您的脚本没有调用任何cv 2函数来进行图形输出,如cv2.namedWindowcv2.imshow

4ioopgfo

4ioopgfo6#

通过https://github.com/NVlabs/instant-ngp/discussions/300解决了我的问题

pip uninstall opencv-python
pip install opencv-python-headless

这似乎是cv2 Python包以及它在Qt中循环方式的问题

相关问题