This guide addresses Qt platform plugin issues when running the Python GUI Menu application on Linux systems, particularly with Wayland display servers like those found on RHEL 8+, Fedora, and Ubuntu 22.04+.
When running PyQt5 applications on Linux systems with Wayland, you might encounter this error:
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.
This happens because:
- Qt is trying to use the X11 (xcb) plugin on a Wayland system
- The xcb plugin may be missing dependencies
- Qt doesn't automatically detect and use appropriate Wayland plugins
We've created an enhanced Linux launcher (run_linux.sh) that:
- Detects your display server (Wayland vs X11)
- Sets appropriate Qt environment variables
- Provides multiple fallback options
- Includes diagnostic tools for troubleshooting
# Use the cross-platform launcher (recommended)
./run.sh
# Or use the Linux-specific launcher directly
./run_linux.sh# Show diagnostic information
./run_linux.sh --debug
# Use custom config file
./run_linux.sh custom_config.yml
# Show help
./run_linux.sh --helpThe enhanced launcher automatically detects your environment:
- Checks for
WAYLAND_DISPLAYenvironment variable - Uses Wayland-compatible Qt plugins:
wayland,wayland-egl,wayland-xcomposite-egl - Sets Wayland-specific Qt options
- Checks for
DISPLAYenvironment variable - Uses X11-compatible Qt plugin:
xcb - Sets X11-specific Qt options
- If primary plugins fail, tries alternative plugins
- Includes minimal platform as last resort for headless testing
- Provides detailed error diagnostics
The application may require additional system packages:
# Install Qt5 dependencies
sudo dnf install qt5-qtbase-gui qt5-qtwayland
# Or with the launcher
./run_linux.sh --install-deps# Install Qt5 dependencies
sudo apt install libqt5gui5 qtwayland5# Install Qt5 dependencies
sudo pacman -S qt5-base qt5-waylandThe enhanced launcher sets several Qt environment variables:
QT_QPA_PLATFORM: Specifies the Qt platform plugin to usewayland: Native Wayland supportwayland-egl: Wayland with EGL backendxcb: X11 supportminimal: Headless mode (diagnostic only)
QT_X11_NO_MITSHM=1: Disables shared memory extensionQT_AUTO_SCREEN_SCALE_FACTOR=1: Enables automatic scalingQT_LOGGING_RULES="qt.qpa.plugin=false": Reduces Qt plugin loggingQT_WAYLAND_DISABLE_WINDOWDECORATION=0: Enables window decorations on Wayland
-
"Could not load the Qt platform plugin 'xcb'"
- Use the enhanced launcher:
./run_linux.sh - Install missing dependencies:
./run_linux.sh --install-deps
- Use the enhanced launcher:
-
Application appears but is unresponsive on Wayland
- Try forcing X11 mode:
WAYLAND_DISPLAY= ./run_linux.sh - Check if your desktop supports XWayland
- Try forcing X11 mode:
-
Font rendering issues
- The launcher sets font-related Qt variables automatically
- Check if your system has the required font packages
-
Application crashes immediately
- Run with debug mode:
./run_linux.sh --debug - Check the diagnostic output for missing dependencies
- Run with debug mode:
You can manually override the platform detection:
# Force Wayland
QT_QPA_PLATFORM=wayland ./run_linux.sh
# Force X11
QT_QPA_PLATFORM=xcb ./run_linux.sh
# Force minimal (diagnostic)
QT_QPA_PLATFORM=minimal ./run_linux.shIf you're setting up the development environment on Linux:
-
Create virtual environment:
python3 -m venv menu_venv source menu_venv/bin/activate -
Install Python dependencies:
pip install PyQt5 PyYAML
-
Install system dependencies:
# RHEL/Fedora sudo dnf install qt5-qtbase-gui qt5-qtwayland python3-devel # Ubuntu/Debian sudo apt install libqt5gui5 qtwayland5 python3-dev
-
Test the application:
./run_linux.sh --debug
When building the standalone executable for Linux:
- The build process will include the enhanced launcher
- The standalone executable handles platform detection internally
- No additional Qt dependencies are needed for the executable
# Build the executable
python build.py
# The resulting package includes both run.sh and run_linux.sh| OS/Desktop | Wayland | X11 | Notes |
|---|---|---|---|
| RHEL 8+ | ✅ | ✅ | Default Wayland, XWayland available |
| Fedora 35+ | ✅ | ✅ | Default Wayland, XWayland available |
| Ubuntu 22.04+ | ✅ | ✅ | Default Wayland, X11 option in login |
| CentOS Stream | ✅ | ✅ | Similar to RHEL |
| openSUSE | ✅ | ✅ | Wayland default on recent versions |
| Arch Linux | ✅ | ✅ | Depends on desktop environment |
If you encounter issues on specific Linux distributions:
- Run
./run_linux.sh --debugand capture the output - Include your distribution details:
cat /etc/os-release - Include desktop environment:
echo $XDG_CURRENT_DESKTOP - Submit an issue with the diagnostic information
Last updated: $(date)