简体   繁体   中英

After installing pyqt5==5.14.0, error shows as Could not load the Qt platform plugin "xcb" in "" even though it was found

I have accidentally installed pyqt5==5.14.0 for testing for pandasGUI as seen in a tutorial in my ubuntu system. However, now i am unable to plot any graphs using matplotlib as it shows error as

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, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
Aborted (core dumped)"

I have seen some solutions suggest for looking into /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so file. But such a file or qt5 directory is not seen in this path in my system.

I just need to get the proper matplotlib functioning back.

You would need to get some debugging information first to point to the right direction. For this you run your command with qt debugging set:

QT_DEBUG_PLUGINS=1 picard

This would (try) to run my picard binary with debugging output in the console/terminal which will give you output similar to:

loaded library "crypto"
loaded library "ssl"
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib64/kde4/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/kde4/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() checking directory path "/home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqeglfs.so"
Found metadata in lib /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqeglfs.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "eglfs"
        ]
    },
    "archreq": 0,
    "className": "QEglFSIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("eglfs")
QFactoryLoader::QFactoryLoader() looking at "/home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqlinuxfb.so"
Found metadata in lib /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqlinuxfb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "linuxfb"
        ]
    },
    "archreq": 0,
    "className": "QLinuxFbIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("linuxfb")
QFactoryLoader::QFactoryLoader() looking at "/home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqminimal.so"
Found metadata in lib /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqminimal.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "minimal"
        ]
    },
    "archreq": 0,
    "className": "QMinimalIntegrationPlugin",
    "debug": false,
    "version": 331520
}

...

Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ...
Cannot load library /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)
QLibraryPrivate::loadPlugin failed on "/home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so" : "Cannot load library /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)"
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, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

This is the critical part indicating a system library file is missing:

Cannot load library /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)

QLibraryPrivate::loadPlugin failed on "/home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so" : "Cannot load library /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)"

As we can see, the library being loaded python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so is itself trying to load a missing linked library libxkbcommon-x11.so.0 as indicated by the "No such file..." error.

You can verify this by using ldd to list the libraries links, for example:

ldd /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so
    linux-vdso.so.1 =>  (0x00007ffc57340000)
    libQt5XcbQpa.so.5 => /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libQt5XcbQpa.so.5 (0x00007f2ef6b4e000)
    libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007f2ef690c000)
    libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007f2ef664d000)
    libz.so.1 => /lib64/libz.so.1 (0x00007f2ef6437000)
    libQt5Gui.so.5 => /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libQt5Gui.so.5 (0x00007f2ef5b06000)
    libQt5DBus.so.5 => /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libQt5DBus.so.5 (0x00007f2ef587a000)
    libQt5Core.so.5 => /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libQt5Core.so.5 (0x00007f2ef5084000)
    libGL.so.1 => /lib64/libGL.so.1 (0x00007f2ef4df8000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2ef4bdc000)
    libX11-xcb.so.1 => /lib64/libX11-xcb.so.1 (0x00007f2ef49da000)
    libxcb-icccm.so.4 => /lib64/libxcb-icccm.so.4 (0x00007f2ef47d5000)
    libxcb-image.so.0 => /lib64/libxcb-image.so.0 (0x00007f2ef45d0000)
    libxcb-shm.so.0 => /lib64/libxcb-shm.so.0 (0x00007f2ef43cc000)
    libxcb-util.so.1 => /lib64/libxcb-util.so.1 (0x00007f2ef41c6000)
    libxcb-keysyms.so.1 => /lib64/libxcb-keysyms.so.1 (0x00007f2ef3fc3000)
    libxcb-randr.so.0 => /lib64/libxcb-randr.so.0 (0x00007f2ef3db3000)
    libxcb-render-util.so.0 => /lib64/libxcb-render-util.so.0 (0x00007f2ef3baf000)
    libxcb-render.so.0 => /lib64/libxcb-render.so.0 (0x00007f2ef39a1000)
    libxcb-shape.so.0 => /lib64/libxcb-shape.so.0 (0x00007f2ef379d000)
    libxcb-sync.so.1 => /lib64/libxcb-sync.so.1 (0x00007f2ef3596000)
    libxcb-xfixes.so.0 => /lib64/libxcb-xfixes.so.0 (0x00007f2ef338e000)
    libxcb-xinerama.so.0 => /lib64/libxcb-xinerama.so.0 (0x00007f2ef318b000)
    libxcb-xkb.so.1 => /lib64/libxcb-xkb.so.1 (0x00007f2ef2f6f000)
    libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f2ef2d47000)
    libXext.so.6 => /lib64/libXext.so.6 (0x00007f2ef2b35000)
    libX11.so.6 => /lib64/libX11.so.6 (0x00007f2ef27f7000)
    libxkbcommon-x11.so.0 => not found
    libxkbcommon.so.0 => /lib64/libxkbcommon.so.0 (0x00007f2ef25b7000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f2ef23b3000)
    libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f2ef20ab000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f2ef1da9000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f2ef1b93000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f2ef17c5000)
    libxkbcommon-x11.so.0 => not found
    libgthread-2.0.so.0 => /lib64/libgthread-2.0.so.0 (0x00007f2ef15c3000)
    libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f2ef12ad000)
    libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f2ef1083000)
    libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f2ef0e7e000)
    libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f2ef0c6e000)
    libpng15.so.15 => /lib64/libpng15.so.15 (0x00007f2ef0a43000)
    libdbus-1.so.3 => /lib64/libdbus-1.so.3 (0x00007f2ef07f3000)
    libicui18n.so.56 => /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libicui18n.so.56 (0x00007f2ef035a000)
    libicuuc.so.56 => /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libicuuc.so.56 (0x00007f2eeffa2000)
    libicudata.so.56 => /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libicudata.so.56 (0x00007f2eee5bf000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f2ef70ab000)
    libGLX.so.0 => /lib64/libGLX.so.0 (0x00007f2eee38d000)
    libGLdispatch.so.0 => /lib64/libGLdispatch.so.0 (0x00007f2eee0d7000)
    libXau.so.6 => /lib64/libXau.so.6 (0x00007f2eeded3000)
    libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f2eedc71000)
    libsystemd.so.0 => /lib64/libsystemd.so.0 (0x00007f2eeda40000)
    libcap.so.2 => /lib64/libcap.so.2 (0x00007f2eed83b000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f2eed633000)
    libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f2eed40c000)
    liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f2eed1e6000)
    liblz4.so.1 => /lib64/liblz4.so.1 (0x00007f2eecfd7000)
    libgcrypt.so.11 => /lib64/libgcrypt.so.11 (0x00007f2eecd56000)
    libgpg-error.so.0 => /lib64/libgpg-error.so.0 (0x00007f2eecb51000)
    libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f2eec937000)
    libdw.so.1 => /lib64/libdw.so.1 (0x00007f2eec6e6000)
    libattr.so.1 => /lib64/libattr.so.1 (0x00007f2eec4e1000)
    libelf.so.1 => /lib64/libelf.so.1 (0x00007f2eec2c9000)

or more concisely ldd /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so | grep -i "not found" ldd /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so | grep -i "not found" you can then see that the error you got in the debugging output is in fact caused by a missing library dependency -- not having anything directly to do with QT.

In this example case, I was on CentOS, so I could use yum to search for what provides the missing library yum provides libxkbcommon-x11 or yum search libxkb to see any packages that might match.

Once the missing package was installed you could see using ldd that all library dependencies are satisfied:

ldd /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so
    linux-vdso.so.1 =>  (0x00007ffd6ea36000)
    libQt5XcbQpa.so.5 => /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libQt5XcbQpa.so.5 (0x00007f3c32187000)
    libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007f3c31f45000)
    libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007f3c31c86000)
    libz.so.1 => /lib64/libz.so.1 (0x00007f3c31a70000)
    libQt5Gui.so.5 => /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libQt5Gui.so.5 (0x00007f3c3113f000)
    libQt5DBus.so.5 => /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libQt5DBus.so.5 (0x00007f3c30eb3000)
    libQt5Core.so.5 => /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libQt5Core.so.5 (0x00007f3c306bd000)
    libGL.so.1 => /lib64/libGL.so.1 (0x00007f3c30431000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f3c30215000)
    libX11-xcb.so.1 => /lib64/libX11-xcb.so.1 (0x00007f3c30013000)
    libxcb-icccm.so.4 => /lib64/libxcb-icccm.so.4 (0x00007f3c2fe0e000)
    libxcb-image.so.0 => /lib64/libxcb-image.so.0 (0x00007f3c2fc09000)
    libxcb-shm.so.0 => /lib64/libxcb-shm.so.0 (0x00007f3c2fa05000)
    libxcb-util.so.1 => /lib64/libxcb-util.so.1 (0x00007f3c2f7ff000)
    libxcb-keysyms.so.1 => /lib64/libxcb-keysyms.so.1 (0x00007f3c2f5fc000)
    libxcb-randr.so.0 => /lib64/libxcb-randr.so.0 (0x00007f3c2f3ec000)
    libxcb-render-util.so.0 => /lib64/libxcb-render-util.so.0 (0x00007f3c2f1e8000)
    libxcb-render.so.0 => /lib64/libxcb-render.so.0 (0x00007f3c2efda000)
    libxcb-shape.so.0 => /lib64/libxcb-shape.so.0 (0x00007f3c2edd6000)
    libxcb-sync.so.1 => /lib64/libxcb-sync.so.1 (0x00007f3c2ebcf000)
    libxcb-xfixes.so.0 => /lib64/libxcb-xfixes.so.0 (0x00007f3c2e9c7000)
    libxcb-xinerama.so.0 => /lib64/libxcb-xinerama.so.0 (0x00007f3c2e7c4000)
    libxcb-xkb.so.1 => /lib64/libxcb-xkb.so.1 (0x00007f3c2e5a8000)
    libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f3c2e380000)
    libXext.so.6 => /lib64/libXext.so.6 (0x00007f3c2e16e000)
    libX11.so.6 => /lib64/libX11.so.6 (0x00007f3c2de30000)
    libxkbcommon-x11.so.0 => /lib64/libxkbcommon-x11.so.0 (0x00007f3c2dc28000)
    libxkbcommon.so.0 => /lib64/libxkbcommon.so.0 (0x00007f3c2d9e8000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f3c2d7e4000)
    libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f3c2d4dc000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f3c2d1da000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f3c2cfc4000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f3c2cbf6000)
    libgthread-2.0.so.0 => /lib64/libgthread-2.0.so.0 (0x00007f3c2c9f4000)
    libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f3c2c6de000)
    libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f3c2c4b4000)
    libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f3c2c2af000)
    libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f3c2c09f000)
    libpng15.so.15 => /lib64/libpng15.so.15 (0x00007f3c2be74000)
    libdbus-1.so.3 => /lib64/libdbus-1.so.3 (0x00007f3c2bc24000)
    libicui18n.so.56 => /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libicui18n.so.56 (0x00007f3c2b78b000)
    libicuuc.so.56 => /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libicuuc.so.56 (0x00007f3c2b3d3000)
    libicudata.so.56 => /home/nas/.local/lib/python3.6/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libicudata.so.56 (0x00007f3c299f0000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f3c326e4000)
    libGLX.so.0 => /lib64/libGLX.so.0 (0x00007f3c297be000)
    libGLdispatch.so.0 => /lib64/libGLdispatch.so.0 (0x00007f3c29508000)
    libXau.so.6 => /lib64/libXau.so.6 (0x00007f3c29304000)
    libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f3c290a2000)
    libsystemd.so.0 => /lib64/libsystemd.so.0 (0x00007f3c28e71000)
    libcap.so.2 => /lib64/libcap.so.2 (0x00007f3c28c6c000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f3c28a64000)
    libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f3c2883d000)
    liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f3c28617000)
    liblz4.so.1 => /lib64/liblz4.so.1 (0x00007f3c28408000)
    libgcrypt.so.11 => /lib64/libgcrypt.so.11 (0x00007f3c28187000)
    libgpg-error.so.0 => /lib64/libgpg-error.so.0 (0x00007f3c27f82000)
    libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f3c27d68000)
    libdw.so.1 => /lib64/libdw.so.1 (0x00007f3c27b17000)
    libattr.so.1 => /lib64/libattr.so.1 (0x00007f3c27912000)
    libelf.so.1 => /lib64/libelf.so.1 (0x00007f3c276fa000)

This is a very specific example in trying to use a freshly built from source MusicBrainz Picard over ssh with X11 Forwarding which considering the package relies on QT AND python which is all being run remotely and the interface forwarded to my local desktop provides many interesting ways for the application to break.

So the operating theory and troubleshooting strategy is that you can use the QT debugging facility to narrow down where the problem lies and in all likelihood it's a missing library (or several) that your system's package manager can provide or in some cases pip for python (or other language specific package managers).

I hope this helps someone else with a similar problem - as I was initially thinking it was a QT5 problem, then a Python problem, then a bug with the software I was trying to run, when it was a missing system library I wouldn't have suspected.

EDIT: I just saw this post as a suggestion and it's pretty much the same advice I have here, but surrounded with a lot more context, so I'll link it here https://stackoverflow.com/a/39725335/1112676

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM