gpt4 book ai didi

qt - 无法在 "xcb"中加载 Qt 平台插件 ""即使找到了

转载 作者:行者123 更新时间:2023-12-03 22:00:25 26 4
gpt4 key购买 nike

这个问题在 Stack Overflow 中被问了好几次。我在几次讨论中尝试了方法,但没有奏效。所以我的OpenCV使用自定义 Qt 构建的库不能正常工作:

import cv2
img = cv2.imread("IMAGE_PATH")
cv2.imshow("frame", img)

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" 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: eglfs, minimal, minimalegl, offscreen, vnc, xcb.

Aborted (core dumped)

我试过的
  • 我尝试设置 export QT_DEBUG_PLUGINS=1并执行一个 Python 脚本,让 OpenCV 绘制图像。错误信息:

  • QFactoryLoader::QFactoryLoader() checking directory path "/home/w/.conda/envs/py36/plugins/platforms" ...
    QFactoryLoader::QFactoryLoader() looking at "/home/w/.conda/envs/py36/plugins/platforms/libqeglfs.so"
    Found metadata in lib /home/w/.conda/envs/py36/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/w/.conda/envs/py36/plugins/platforms/libqminimal.so"
    Found metadata in lib /home/w/.conda/envs/py36/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/w/.conda/envs/py36/plugins/platforms/libqminimalegl.so"
    Found metadata in lib /home/w/.conda/envs/py36/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/w/.conda/envs/py36/plugins/platforms/libqoffscreen.so"
    Found metadata in lib /home/w/.conda/envs/py36/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/w/.conda/envs/py36/plugins/platforms/libqvnc.so"
    Found metadata in lib /home/w/.conda/envs/py36/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/w/.conda/envs/py36/plugins/platforms/libqxcb.so"
    Found metadata in lib /home/w/.conda/envs/py36/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/w/.conda/envs/py36/bin/platforms" ...
    Cannot load library /home/w/.conda/envs/py36/plugins/platforms/libqxcb.so: (/home/w/.conda/envs/py36/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/w/.conda/envs/py36/plugins/platforms/libqxcb.so" : "Cannot load library /home/w/.conda/envs/py36/plugins/platforms/libqxcb.so: (/home/w/.conda/envs/py36/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 "" 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.

    Aborted (core dumped)
  • 我尝试设置 export LD_LIBRARY_PATH=/opt/Qt5.14.0/5.14.0/gcc_64/lib:$LD_LIBRARY_PATH~/.bashrc文件,但它没有解决。
  • 我尝试重新安装 Qt5但它没有用。
  • 我尝试使用 ldd正如人们所说,但我不太确定我应该查看哪些信息。

  • 如果相关
  • 首先,如果相关,我在 Ubuntu 16.04 上安装了 Anaconda,并创建了一个通用 Python 环境名称 py36安装了几个库的位置。我尝试运行 conda list以下是一些软件包:

  •  ...
    pyqt 5.9.2 py36h05f1152_2
    qt 5.9.7 h5867ecd_1
    vtk 8.2.0 py36haa4764d_200
    ...

    老实说,我不知道这些库是什么时候安装的(当我安装其他软件包时它们会自动安装。)
  • 接下来,我下载了Qt offline installer并安装到 /opt/Qt-5.14.0 .
  • 接下来,我使用以下设置编译了 OpenCV 3.4.9。我进展顺利,没有任何错误。 (之后我在 conda 环境中设置符号链接(symbolic link) cv2.so 以指向 /opt 中构建的 OpenCV 库。)

  • cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/opt/OpenCV/opencv-3.4.9 \
    -D CMAKE_PREFIX_PATH="/opt/Qt5.14.0/5.14.0/gcc_64/lib/cmake;/opt/vtk-8.2.0/lib/cmake;/opt/g2o/lib/cmake" \
    -D OPENCV_EXTRA_MODULES_PATH=/home/w/OpenCV/opencv-3.4.9/opencv_contrib-3.4.9/modules \
    -D PYTHON3_EXECUTABLE=/home/w/.conda/envs/py36/bin/python3 \
    -D WITH_OPENGL=ON \
    -D WITH_V4L=ON \
    -D WITH_LIBV4L=ON \
    -D WITH_FFMPEG=ON \
    -D WITH_VTK=ON \
    -D WITH_QT=ON \
    -D WITH_GTK=ON \
    ..

    最佳答案

    错误似乎是 Qt图书馆冲突。链接器找不到正确的 Qt我定制的 /opt 所需的库(安装在 OpenCV 文件夹中)在 conda 虚拟环境中。这是因为还有一个 Qt安装在虚拟环境中的库。这可以通过使用 ldd 找到. (对不起,这是前段时间,所以我没有输出。)

    正如预期的那样,通过删除虚拟 conda 环境中所有与 Qt 相关的库,OpenCV使用 Qt 构建的库(安装在 /opt 文件夹中)像往常一样正常工作。

    关于qt - 无法在 "xcb"中加载 Qt 平台插件 ""即使找到了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59809703/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com