Error
warnings.warn(
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: vnc, vkkhrdisplay, xcb, wayland-egl, minimal, eglfs, linuxfb, minimalegl, wayland, offscreen.
Solution
If you have correctly installed Qt5 and set the QT_QPA_PLATFORM_PLUGIN_PATH
, but are still encountering the error, there may be some additional issues to address. Here are some further steps to troubleshoot and resolve the issue:
Step 1: Verify the Installation of Required Libraries
Ensure all required libraries are installed:
sudo apt-get install qt5-default qttools5-dev-tools libxcb-xinput0 libx11-xcb1 libxcb1 libxcb-glx0 libxcb-keysyms1 libxcb-image0 libxcb-shm0 libxcb-icccm4 libxcb-sync1 libxcb-xfixes0 libxcb-shape0 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xkb1 libxkbcommon-x11-0 libxcb-cursor0 libxcb-xinerama0-dev
Step 2: Check Permissions
Ensure that the user running the application has sufficient permissions to access the directory and files:
ls -l /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/
Verify that the permissions allow read and execute access.
Step 3: Use LD_LIBRARY_PATH
Set the LD_LIBRARY_PATH
to include the Qt libraries:
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
Step 4: Verify the Plugin Path
Double-check the exact path to the libqxcb.so
file. Sometimes the plugin might be in a subdirectory like platforms
:
find /usr/lib/x86_64-linux-gnu/qt5/plugins/ -name libqxcb.so
If the file is located in a subdirectory (e.g., /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/
), you might need to update the QT_QPA_PLATFORM_PLUGIN_PATH
accordingly:
export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/
Step 5: Check for Conflicting Qt Versions
Ensure there are no conflicting Qt versions installed. You can check for multiple installations of Qt:
dpkg -l | grep qt
If you find multiple versions, it might help to remove the conflicting ones.
Step 6: Reinstall Qt Packages
Reinstall the Qt packages to ensure all files are correctly installed:
sudo apt-get install --reinstall qt5-default qttools5-dev-tools
Step 7: Debugging with QT_DEBUG_PLUGINS
Enable debugging for Qt plugins to get more detailed error messages:
export QT_DEBUG_PLUGINS=1
python main.py --robot=franka
This will provide more information about why the xcb
plugin is failing to load.
Step 8: Use an Alternative Platform Plugin
As a temporary workaround, you could try using an alternative platform plugin like offscreen
or wayland
:
export QT_QPA_PLATFORM=offscreen
Or:
export QT_QPA_PLATFORM=wayland
Step 9: Virtual Environment Dependencies
Ensure that your virtual environment has access to the system’s Qt libraries. You might need to link the system libraries to your virtual environment:
ln -s /usr/lib/x86_64-linux-gnu/qt5 /home/miniconda3/envs/py39/lib/
Final Check
After performing these steps, try running your script again:
python main.py --robot=franka
If the issue persists, please provide the detailed output from the QT_DEBUG_PLUGINS=1
run, as it will give more insight into what is going wrong.