无法加载Qt平台插件"xcb",在“"中即使被发现 [英] Could not load the Qt platform plugin "xcb" in "" even though it was found

查看:409
本文介绍了无法加载Qt平台插件"xcb",在“"中即使被发现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在堆栈溢出中多次询问了此问题.我在几次讨论中都尝试了方法,但是没有用.因此,使用自定义 Qt 构建的 OpenCV 库无法正常工作:

This question is asked several times in Stack Overflow. I tried methods in several discussions but it didn't work. So my OpenCV library which was built with custom Qt doesn't work properly:

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 并执行具有OpenCV绘制图像的Python脚本.错误消息:
  • What I have tried

    • I tried setting export QT_DEBUG_PLUGINS=1 and execute a Python script having OpenCV plotting an image. Error message:
    • 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)
      

      • 我尝试在〜/.bashrc 文件中设置 export LD_LIBRARY_PATH =/opt/Qt5.14.0/5.14.0/gcc_64/lib:$ LD_LIBRARY_PATH 解决.
      • 我尝试重新安装 Qt5 ,但这没有用.
      • 我曾尝试像人们所说的那样使用 ldd ,但是我不确定应该查看哪些信息.
        • I tried setting export LD_LIBRARY_PATH=/opt/Qt5.14.0/5.14.0/gcc_64/lib:$LD_LIBRARY_PATH in ~/.bashrc file but it didn't solve.
        • I tried reinstalling Qt5 but it didn't work.
        • I tried using ldd as people said but I am not so sure what information I should be looking.
          • 首先,如果相关,我在Ubuntu 16.04上安装了Anaconda,并创建了一个通用的Python环境名称 py36 ,其中安装了多个库.我尝试运行 conda list ,以下是其中一些软件包:
          • First, if relevant, I have Anaconda installed on Ubuntu 16.04 and I created a general Python environment name py36 where several libraries are installed. I tried running conda list and the following are some of the packages:
           ...
           pyqt                      5.9.2            py36h05f1152_2  
           qt                        5.9.7                h5867ecd_1
           vtk                       8.2.0           py36haa4764d_200
           ...
          

          老实说,我不知道何时安装这些库(我在安装其他软件包时会自动安装它们).

          I honestly didn't know when these libraries are installed (They came installed automatically when I installed other packages.)

          • 接下来,我下载了 Qt离线安装程序,并将其安装到/opt/Qt-5.14.0 .
          • 接下来,我使用以下设置编译了OpenCV 3.4.9.我一切顺利,没有任何错误.(此后,我在conda环境中设置了symlink cv2.so 指向/opt 中已构建的OpenCV库.)
          • Next, I downloaded Qt offline installer and installed to /opt/Qt-5.14.0.
          • Next, I compiled OpenCV 3.4.9 using the following settings. I went well without any errors. (After that I set symlink cv2.so in the conda environment to point to the built OpenCV library in /opt.)
          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 文件夹中),这是我在conda虚拟机中自定义构建的 OpenCV 所必需的环境.这是因为在虚拟环境中安装了另一个 Qt 库.这可以通过使用 ldd 找到.(对不起,是前一段时间,所以我没有输出.)

          The error seems to be the Qt library conflict. The linker couldn't find the correct Qt library (installed in /opt folder) which is required by my custom built OpenCV in the conda virtual environment. This is because there is another Qt library installed in the virtual environment. And this can be found by using ldd. (Sorry, it was some time ago so I don't have the output.)

          按预期,通过删除虚拟conda环境中的所有与Qt相关的库,使用 Qt 构建的 OpenCV 库(安装在/opt中文件夹)照常运行.

          As expected, by removing all the Qt-related libraries in the virtual conda environment, the OpenCV library which was built with Qt (installed in /opt folder) works properly as usual.

          这篇关于无法加载Qt平台插件"xcb",在“"中即使被发现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆