Module "org.kde.kirigami" is not installed

The errors like:

module "org.kde.kirigami" is not installed
module "org.kde.desktop" is not installed
kf.kirigami.platform: Failed to find a Kirigami platform plugin for style "Fusion"

mean that the Qt Quick QML engine can’t find some required QML modules and style plugins.

  • The first two errors indicate that the Kirigami (org.kde.kirigami) and KDE desktop style (org.kde.desktop) QML modules are missing from the engine’s import paths.
  • The third error occurs because Kirigami is trying to use the Fusion style, but the corresponding Kirigami platform plugin for that style is not found. This usually happens when the style is not explicitly set to org.kde.desktop and the fallback style (Fusion) is used instead.

When using PyQt6 inside a virtual environment, Qt sometimes won’t automatically find the system QML and plugin directories, so you need to manually configure them before loading your QML files.

Below is a working example for PyQt6. If you’re using PySide6, the logic is the same, but class/module names will change slightly.

import os
import sys
from PyQt6.QtCore import QUrl
from PyQt6.QtGui import QGuiApplication
from PyQt6.QtQml import QQmlApplicationEngine

# 1. Construct the path to the PyQt6 plugins directory inside your virtual environment
pyqt6_plugins_path = os.path.join(
    sys.prefix,  # Path to your virtual environment root
    'lib',
    f'python{sys.version_info.major}.{sys.version_info.minor}',
    'site-packages', 'PyQt6', 'Qt6', 'plugins'
)

# 2. Tell Qt where to find its plugins
#    We combine the PyQt6 plugin path with the system-wide Qt plugin path.
os.environ['QT_PLUGIN_PATH'] = f'{pyqt6_plugins_path}:/usr/lib/qt6/plugins'

# 3. Set the style for Qt Quick Controls to "org.kde.desktop"
#    This avoids the fallback to "Fusion" and ensures the Kirigami platform plugin can be found.
os.environ["QT_QUICK_CONTROLS_STYLE"] = "org.kde.desktop"

# 4. Create the Qt application and QML engine
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()

# 5. Add the system QML import path so Kirigami and KDE styles can be found
#    This is where your OS stores the QML modules like org.kde.kirigami.
engine.addImportPath("/usr/lib/qt6/qml")

# 6. Now load your main QML file
engine.load(QUrl.fromLocalFile("main.qml"))

if not engine.rootObjects():
    sys.exit(-1)

sys.exit(app.exec())

Why this works

  • engine.addImportPath("/usr/lib/qt6/qml"): Makes the QML engine look in the system directory where org.kde.kirigami and org.kde.desktop are installed. Without this, it will only search in your virtual environment’s limited QML path.
  • QT_PLUGIN_PATH: Ensures that Qt can find the platform and style plugins it needs for rendering Kirigami components.
  • QT_QUICK_CONTROLS_STYLE: Forces Kirigami to use the KDE desktop style instead of falling back to the “Fusion” style. This prevents the Failed to find a Kirigami platform plugin for style "Fusion" warning and ensures the application uses the correct native look.

If you’re on another platform (e.g., Windows or macOS), you’ll need to adjust the paths accordingly.