RoboStack / robostack.github.io

166 stars 16 forks source link

Could not load the Qt platform plugin "xcb" in "" even though it was found. #48

Closed tyseng92 closed 3 months ago

tyseng92 commented 3 months ago

After creating ros_env by following the guide in Robostack, running rviz2 will have the following output:

qt.qpa.xcb: could not connect to display :0
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, minimal, minimalegl, offscreen, vnc, webgl, xcb.

Aborted (core dumped)

After setting the environment variable, export QT_DEBUG_PLUGINS=1, output error is listed below:

Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/home/user/miniforge3/envs/ros_env/bin/platforms" ...
loaded library "/home/user/miniforge3/envs/ros_env/plugins/platforms/libqxcb.so"
qt.qpa.xcb: could not connect to display :0
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, minimal, minimalegl, offscreen, vnc, webgl, xcb.

Aborted (core dumped)

Running ldd /home/user/miniforge3/envs/ros_env/plugins/platforms/libqxcb.so does not show any errors.

tyseng92 commented 3 months ago

I have found out the solution. I have set the environment variable of DISPLAY to 0 export DISPLAY=:0 in the .bashrc file. Changing the value to 1 export DISPLAY=:1.0 will fix the error.