When I tried to use PyQt5 with wsl2, I had a trouble, so a memorandum. The Japanese article said that it would be solved if only one apt install was done, but I didn't.
--I want to use PyQt5 --The environment here is Ubuntu 18.04 on wsl2, but it should be common on Ubuntu. --It is assumed that the GUI environment of wsl (2) has already been built. Like putting in Xserver. --If you want to know here, please also see Installation of WSL2, construction of GUI environment and gnome-open of sshfs !!.
$ main.py
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
sudo apt install libxkbcommon-x11-0
This was not enough. This is also necessary!
First, find out where libqeglfs.so
is.
find / -name libqeglfs.so
Such. However, the execution time may be difficult. For example
export QT_DEBUG_PLUGINS=1
When you put it in debug mode and execute the target Python file
Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/path/to/python/bin/platforms" ...
Cannot load library /path/to/python/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (libxcb-icccm.so.4: cannot open shared object file: No such file or directory)
QLibraryPrivate::loadPlugin failed on "/path/to/python/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /home/path/to/python/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (libxcb-icccm.so.4: cannot open shared object file: No such file or directory)"
Something like this appears near the end (the path to Python has been rewritten as path / to / python
).
If you find this https://forum.qt.io/topic/115732/could-not-load-the-qt-platform-plugin-xcb-in-even-though-it-was-found And so on
ldd /path/to/python/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so
You should do it. If it's hard to see, you can add | grep" not found "
.
This will tell you what is missing, so for example,
$ ldd /path/to/python/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so | grep "not found"
libxcb-icccm.so.4 => not found
libxcb-image.so.0 => not found
libxcb-keysyms.so.1 => not found
libxcb-render-util.so.0 => not found
libxcb-xinerama.so.0 => not found
libxcb-icccm.so.4 => not found
libxcb-image.so.0 => not found
libxcb-keysyms.so.1 => not found
libxcb-render-util.so.0 => not found
libxcb-xinerama.so.0 => not found
Because it was
sudo apt install libxkbcommon-x11-0
sudo apt install libxcb-icccm4
sudo apt install libxcb-image0
sudo apt install libxcb-keysyms1
sudo apt install libxcb-render-util0
sudo apt install libxcb-xinerama0
Then it started to work. Congratulations.
Recommended Posts