run pyqt5 program, get error: This application failed to start because it could not find or load the Qt platform plugin "xcb" in "" - pyqt5

I have wirted a program with pyQt5 on ubuntu 16.04, when i run, i get the following error:
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
Reinstalling the application may fix this problem.

I may find the answer. I have install Qt5 and pyQt5 on my ubuntu, there libs may get conflicted. To fix this, I open a new terminal, and reset LD_LIBRARY_PATH without Qt's lib. Then run the program in this terminal. It works well.

Related

Problem running a PyQt5 project in WSLg - no application window shows up

I am running WSL2 under Windows 10.
If I type "gedit &" into the WSL console, the Gedit application window pops up. Thus I assume that WSLg properly works.
Next, I am trying to run the following PyQt5 project:
https://github.com/rafaelpadilla/review_object_detection_metrics
However, no application window pops up this time, although no error message appears either.
First of all, I do wonder whether this could work at all with WSL!?
Appendix for additional context:
I am not using conda because of licensing issues, but a combination of pyenv + poetry instead. First I had problems with a missing library (libxcb.so), which I could solve by running "sudo apt python-pyqt5". Now everything seems to work, except from no application window being shown.
UPDATE:
I tried with "/src/pyqt-official/qtdemo/qtdemo.py" from the official PyQt Examples github repository and I observed exactly the same issue.
There is no error message. Last prompt informs me that the "xcb plugin was loaded“, then nothing happens. In particular, no window is showing up.
Some related observations:
(1) I haven't yet updated my grafics card driver to support vGPUs. However, Gedit works and opens in a separate window.
(2) Unless I do "sudo apt install python3-pyqt", I receive an error message saying that it cannot find "libxcb.so". However, I am running the code in a virtual pyenv/poetry environment, which is separate from the system python installation. I don't understand why "sudo apt install python3-pyqt" makes a difference here. Shouldn't installing "PyQt5" with poetry obtain a wheel that comes with all libraries already compiled? I don't understand how all of this is playing together.
Open Questions:
Do you think the driver issue could be an explanation? I actually cannot imagine that. I thought it is only about better performance for OpenGL applications.
Can you explain observation (2)?
What else can I do?
First of all, I do wonder whether this could work at all with WSL!?
I can't tell you if that particular application will run under WSL, but my expectation is that it will. As far as I can tell in its dependencies there doesn't seem to be any reliance on GPU compute. That, to me, would be the trickiest part to configure under WSL (but is still typically possible). However, there may be other dependencies (not covered below) that you need to get running before the application can work.
What I can confirm is that PyQt works under WSL just fine. However, keep in mind that a default Ubuntu installation under WSL is based on a non-GUI Ubuntu Server distribution, rather than standard Ubuntu (with a desktop and GUI).
This means that Ubuntu Server is often missing system level libraries needed for GUI support, which appears to be the case here.
I don't understand why "sudo apt install python3-pyqt" makes a difference here. Shouldn't installing "PyQt5" with poetry obtain a wheel that comes with all libraries already compiled?
Poetry and/or Pip manage the Python library dependencies, but those Python libraries still require the native system library dependencies. That's where sudo apt install python3-pyqt5 comes in. Under a desktop Ubuntu system, most of these libraries would already be in place. However, with Ubuntu Server/WSL, they aren't.
For reference, here's my configuration. On a freshly initialized Ubuntu 22.04 WSL2 distribution:
sudo apt update && sudo apt upgrade -y
sudo apt install python3-venv python3-pyqt5
mkdir -p src/pyqt_test
cd src/pyqt_test
python3 -m venv .venv
source .venv/bin/activate
pip install pyqt5
I was then able to create and run the following, taken from Learn Python PyQt:
import sys
from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
windows = QtWidgets.QWidget()
windows.resize(500,500)
windows.move(100,100)
windows.show()
sys.exit(app.exec_())
The window displayed correctly.

How to install gazebo on WSL Ubuntu 20.04

I am running Ubuntu 20.04 on a Windows machine (Windows 10) using WSL (WSL 2), and I am unable to get Gazebo to work. I first installed ROS noetic using robostack, following the instructions from here, then I installed Gazebo in the robostackenv with conda install -c conda-forge gazebo. Since I am using WSL, I setup vcxsrv to allow GUI windows to open, I tested this using nautilus (a file explorer application for Ubuntu) and I am able to open the GUI with no problems. However, after installing Gazebo, if I run then it, I only get the initial splash screen that looks like Gazebo is about to start, and then it just crashes with no error messages or anything. I am seeing some messages printed to the console before it crashes, which are:
(robostackenv) $ gazebo
NVD3D10: CPU cyclestats are disabled on client virtualization
NVD3D10: CPU cyclestats are disabled on client virtualization
NVD3D10: CPU cyclestats are disabled on client virtualization
NVD3D10: CPU cyclestats are disabled on client virtualization
NVD3D10: CPU cyclestats are disabled on client virtualization
(robostackenv) $
I'm not sure why Gazebo isn't loading and I'm hoping that I just need to install an extra package or something to fix it. Does anyone know how I can get it working?
One other issue that might be helpful too is that even though I AM able to run nautilus, I am also unable to run GIMP, so it is possible that this is also related to the Gazebo issue. When I run GIMP I see a very similar issue as I do when I run Gazebo, where I get the initial splash screen but then it crashes after a few seconds without actually loading anything. The error messages for GIMP are different though:
(robostackenv) $ gimp
Error spawning command line “dbus-launch --autolaunch=5cecfec9bed410f984c88e9f62869edc --binary-syntax --close-stderr”: Child process exited with code 1
(gimp:14200): Gtk-WARNING **: 22:30:31.771: Unable to locate theme engine in module_path: "pixmap",
(gimp:14200): Gtk-WARNING **: 22:30:31.771: Unable to locate theme engine in module_path: "pixmap",
...
(gimp:14200): Gtk-WARNING **: 22:30:31.772: Unable to locate theme engine in module_path: "pixmap",
(gimp:14200): Gtk-WARNING **: 22:30:31.772: Unable to locate theme engine in module_path: "pixmap",
(gimp:14200): Gtk-WARNING **: 22:30:31.773: Unable to locate theme engine in module_path: "pixmap",
gimp: Fatal IO error 0 (Success) on X server 172.31.176.1:0.
(script-fu:14227): LibGimpBase-WARNING **: 22:30:34.541: script-fu: gimp_wire_read(): error
(robostackenv) $
According to this Github comment, the first error message you are seeing is from the nVidia Preview WSL driver.
Make sure that you have the latest nVidia Windows driver installed, and hopefully that will take care of it. That could also be related to the Gimp issue, of course.

Gazebo GUI Not Showing Up when running WSL2 Graphics on Windows 11

I am attempting to use ROS with the Gazebo GUI. I recently upgraded to Windows 11 for the WSL GUI support and have the gedit GUI working. However, when I run the command $ gazebo, the GUI does not open.
Running $ gazebo --verbose gives the following error messages
[Err] [RenderEngine.cc:749] Can't open display: :0
[Err] [GuiIface.cc:124] 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, xcb.
After enabling the QT Debug environment variable using export export QT_DEBUG_PLUGINS=1 and rerunning the gazebo command with the verbose option set, It shows me
[Dbg] [GuiIface.cc:112] Got keys from plugin meta data ("xcb")
[Dbg] [GuiIface.cc:112] QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ...
[Dbg] [GuiIface.cc:112] loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so"
I believe that I have all of the necessary packages installed from this output, so I am wondering why gazebo is not showing up. I have tried uninstalling/reinstalling gazebo to no avail.
Thank you so much for your time. If I get this problem sorted out, I will post. Please let me know if any other system/output information is needed.
Other information:
I am not using X Server because the Windows 11 upgrade does not require it for graphical WSL applications (but did try it with X Server installed just in case)
I have tinkered around with the ~/.bashrc profile. DISPLAY=0:0 option was set, but I deleted this because Windows 11 did not need it (or so I think?)
Solution:
After reading up online, I found this answer to a similar question to mine.
https://superuser.com/questions/1681647/windows-11-wsl-not-opening-gui-in-my-ubuntu-shell
Getting ubuntu and re-installing gazebo on that worked. Now I can open up the Gazebo GUI.

Psychopy stack smashing detected

I am trying to execute the following basic psychopy (version 2021.2.3) code through the Python 3.6.13 console:
import psychopy.visual as pv
pv.Window()
Which gives the following error.
*** stack smashing detected ***: <unknown> terminated
Aborted (core dumped)
The only related topic I can find is on the psychopy forum with no answers
I'm running this on an Ubuntu 18.04.05 machine. The machine is initialized as a headless server, but I am trying to run this through RDP.
I installed psychopy using pip inside a conda environment. Initially I was getting errors related to wxPython. When I manually installed wxPython from a whl file that error was resolved and error in this question appeared.
My guess is that this is to do with the version of one of the libraries but very hard to tell from this limited info.
What version of PsychoPy are you trying to install and by what means are you installing it? Are you running from the app or is this a script you're trying to launch from the terminal? ie. trying to work out what parts of PsychoPy this is affecting (the app, the visual lib, the gui libs...?)
I had a very similar problem on ubuntu 18.04.5, psychopy 3.2.4, no headless server. I suspect that the problem is general but ubuntu/drivers related.
My solution was to update the system and to install&switch to a proprietary NVIDIA driver.

Packaging with Pyinstaller - PyQt5 setStyle ignored

I'm actually have an similar issue as described here after update python, pyistaller, pyqt5, pyqt5-tools. Before I got the desired "Windows Vista-style" without app.setStyle('windowsvista') when I run the compiled stand-alone executable.
Now I got the Windows "Classic-style" instead. If I start the application in PyCharm it will use the desired "Windows Vista-style".
Currently installed on Win7 64bit:
Python : 3.6.4
PyInstaller: 3.3.1
PyQt5 : 5.10
pyqt5-tools: 5.9.0.1.2 (update to 5.9.1.1 doesn't work)
Does anyone have any idea why PyInstaller ignored the style?
The error seems to have been fixed in a unmerged branch of PyInstaller. More information can be found on the GitHub pull request conversation, but reinstalling PyInstaller using pip install https://github.com/bjones1/pyinstaller/archive/pyqt5_fix.zip fixed the same style issue for me on Mac.