PyQt5: Missing libQt5Gui.so.5

Hello,
I’m using NVIDIA Jetson Tx2 on Ubuntu 16.04 with Python3. I got a problem about PyQt5.

import PyQt5

That’s OK.

from PyQt5 import QtGui

This will lead to the problem of “ImportError: libQt5Gui.so.5: cannot open shared object file: No such file or directory”.

PyQt5 was installed by apt. And I tried to compile Qt5, it failed. Maybe someone else had installed another Qt version in my device.

make[7]: Leaving directory '/home/nvidia/qt/qtbase/src/plugins/platforms/xcb/gl_integrations/xcb_egl'
make[6]: Leaving directory '/home/nvidia/qt/qtbase/src/plugins/platforms/xcb/gl_integrations'
make[5]: Leaving directory '/home/nvidia/qt/qtbase/src/plugins/platforms/xcb'
make[4]: Leaving directory '/home/nvidia/qt/qtbase/src/plugins/platforms'
make[3]: Leaving directory '/home/nvidia/qt/qtbase/src/plugins'
Makefile:693: recipe for target 'sub-plugins-make_first' failed
make[2]: *** [sub-plugins-make_first] Error 2
make[2]: Leaving directory '/home/nvidia/qt/qtbase/src'
Makefile:48: recipe for target 'sub-src-make_first' failed
make[1]: *** [sub-src-make_first] Error 2
make[1]: Leaving directory '/home/nvidia/qt/qtbase'
Makefile:83: recipe for target 'module-qtbase-make_first' failed
make: *** [module-qtbase-make_first] Error 2

Do you have this file? “ls /usr/lib/aarch64-linux-gnu/libQt5Gui.so*”.

/usr/lib/aarch64-linux-gnu/libQt5Gui.so.5.5.1

If not, do you show a package from:

dpkg -l | grep libqt5gui5

If you have that, then probably you need to tell the package where to find it. If not, then you need to install libqt5gui5.

Hello linuxdev,

I just copied the Qt5 dynamic library from another Jetson TX2 and set the environment. It works. Thanks a lot!

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/nvidia/libQt5/QT5-LIB/

I ran into a very similar problem with the same error message. First, debug some by turning on

export QT_DEBUG_PLUGIN=1

from the linux command line and rerun the application. For me this revealed the following:

“Cannot load library /home/…/miniconda3/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)”

“Cannot load library /home/…/miniconda3/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)”

It’s also useful to ldd the dysfunctional .so file. Ex:

>ldd /home/.../miniconda3/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so

Indeed, I was missing libxkbcommon-x11.so.0 and libxkbcommon-x11.so.0. Next, check your architecture using dpkg from the linux command line. (For me, the command “arch” gave a different and unhelpful result)

dpkg --print-architecture #result for me: amd64

I then googled “libxkbcommon-x11.so.0 ubuntu 18.04 amd64”, and likewise for libxkbcommon-x11.so.0, which yields those packages on packages.ubuntu.com. That told me, in retrospect unsurprisingly, I’m missing packages called libxkbcommon-x11-0 and libxkbcommon-0, and that installing those packages will include the needed files, but the dev versions will not. Then the solution:

sudo apt-get update
sudo apt-get install libxkbcommon0
sudo apt-get install libxkbcommon-x11-0