2

I'm using PyQt5 for the first time, and my instructor has given me some basic code to run. We're using an Ubuntu bash shell on Windows 10 in a virtual environment. However, it says that the plugin could not be initialized.

I've tried reinstalling Qt with

    pip install pyqt5

and

    pip3 install pyqt5

as well as exporting the debug log with

    export QT_DEBUG_PLUGINS = 1

I've also tried

    sudo apt install lbqt5x11extras-dev
    sudo apt-get install libxkbcommon-x11-dev

and python ldd libqxcb.so shows no missing dependencies.

The code I used:

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel

my_qt_app = QApplication(sys.argv)

It crashes on that last line.

The debug log give this:

Got keys from plugin meta data ("xcb")
loaded library "/mnt/c/Users/cture/Desktop/envs/cst205env/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so"
qt.qpa.xcb: could not connect to display
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 output of ldd libqxcb.so

linux-vdso.so.1 (0x00007fffc4d21000)
libQt5XcbQpa.so.5 => /mnt/c/Users/cture/Desktop/envs/cst205env/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libQt5XcbQpa.so.5 (0x00007fa7fbc50000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007fa7fba00000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007fa7fb740000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fa7fb520000)
libQt5Gui.so.5 => /mnt/c/Users/cture/Desktop/envs/cst205env/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libQt5Gui.so.5 (0x00007fa7facd0000)
libQt5DBus.so.5 => /mnt/c/Users/cture/Desktop/envs/cst205env/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libQt5DBus.so.5 (0x00007fa7faa30000)
libQt5Core.so.5 => /mnt/c/Users/cture/Desktop/envs/cst205env/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libQt5Core.so.5 (0x00007fa7fa280000)
libGL.so.1 => /usr/lib/x86_64-linux-gnu/libGL.so.1 (0x00007fa7f9ff0000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa7f9dd0000)
libX11-xcb.so.1 => /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007fa7f9bc0000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fa7f9990000)
libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007fa7f9770000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007fa7f9550000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fa7f9210000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa7f8e70000)
libxkbcommon-x11.so.0 => /usr/lib/x86_64-linux-gnu/libxkbcommon-x11.so.0 (0x00007fa7f8c60000)
libxkbcommon.so.0 => /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0 (0x00007fa7f8a20000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa7f8800000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fa7f8470000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa7f8250000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa7f7e50000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007fa7f7c40000)
libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fa7f7920000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fa7f76d0000)
libpng16.so.16 => /usr/lib/x86_64-linux-gnu/libpng16.so.16 (0x00007fa7f7490000)
libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007fa7f7240000)
libicui18n.so.56 => /mnt/c/Users/cture/Desktop/envs/cst205env/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libicui18n.so.56 (0x00007fa7f6da0000)
libicuuc.so.56 => /mnt/c/Users/cture/Desktop/envs/cst205env/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libicuuc.so.56 (0x00007fa7f69e0000)
libicudata.so.56 => /mnt/c/Users/cture/Desktop/envs/cst205env/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libicudata.so.56 (0x00007fa7f4fe0000)
/lib64/ld-linux-x86-64.so.2 (0x00007fa7fc400000)
libGLX.so.0 => /usr/lib/x86_64-linux-gnu/libGLX.so.0 (0x00007fa7f4da0000)
libGLdispatch.so.0 => /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007fa7f4ae0000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fa7f48d0000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fa7f46c0000)
libxcb-xkb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-xkb.so.1 (0x00007fa7f4490000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fa7f4210000)
libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007fa7f3f80000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007fa7f3d60000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fa7f3b50000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fa7f3910000)
liblz4.so.1 => /usr/lib/x86_64-linux-gnu/liblz4.so.1 (0x00007fa7f36f0000)
libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007fa7f33d0000)
libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007fa7f31b0000)```
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • 1
    from *libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory* execute `sudo apt-get install libxkbcommon-x11-dev` – eyllanesc Sep 25 '19 at 19:02
  • @eyllanesc That seems to have fixed some of the problem, but a similar error keeps showing up. I've updated my question with the attempted solutions and new error – KnightOfHeart Sep 25 '19 at 19:48
  • 1
    If you want to avoid problems I recommend using the Ubuntu pyqt5: `sudo apt-get install python3-pyqt5 python-pyqt` https://stackoverflow.com/questions/36757752/how-to-install-pyqt5-in-python-3-ubuntu-14-04 – eyllanesc Sep 25 '19 at 19:51
  • No change there, either. Same error message Is the fact that I'm using a virtual environment relevant at all? – KnightOfHeart Sep 25 '19 at 20:06
  • Mmm, you should clearly state what your environment is, if you don't mention anything then it will be assumed that the system environments will be. so my attempts work for ubuntu python, not for virtualenv. By other hand, Is venv active? Have you reinstalled pyqt5 in the venv? – eyllanesc Sep 25 '19 at 20:08
  • Yes, the venv is active and pyqt5 is installed in the venv. I've been doing all the work in the venv from the ubuntu bash shell – KnightOfHeart Sep 25 '19 at 20:13
  • what is the output of `ldd /mnt/c/Users/cture/Desktop/envs/cst205env/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so`? – eyllanesc Sep 25 '19 at 20:15
  • It's a big list of what I'm guessing are dependencies. None of them are listed as not found. – KnightOfHeart Sep 25 '19 at 20:18
  • Okay, but put it in your question, I want to analyze what Qt libraries point to since if you are using PyQt5 from pypi it uses a version of Qt 5.13 but if for some reason they point to the Qt of the OS I doubt it is from that version ( Ubuntu uses Qt from old versions by default) then it would explain your problem. – eyllanesc Sep 25 '19 at 20:22
  • Oh I see. Thanks! - Well that was interesting. I just ran it outside my virtual environment, and it seemed to work a lot better. The only thing it failed at was connecting to a display. – KnightOfHeart Sep 25 '19 at 20:22
  • Try uninstalling `lbqt5x11extras-dev` and reinstall pyqt5 with pip. – eyllanesc Sep 25 '19 at 20:29
  • I tried running `pip uninstall lbqt5x11extras-dev` but it says it couldn't locate the package. Uninstalling and reinstalling pyqt5 with pip didn't seem to change anything. Oddly, when I run it in my venv, the Qt platform plugin can't be initialized, but when I run it outside my venv, it does initialize it, it just can't connect to the display. – KnightOfHeart Sep 25 '19 at 20:39
  • Hello, Any luck on finding a solution for this problem ? – D. LaRocque Oct 01 '20 at 17:12

0 Answers0