Skip to content

Fix crash when PyQt6 modules are partially installed#1170

Closed
Copilot wants to merge 3 commits into
fix_debian_qt6_multimedia_crashfrom
copilot/fix-crash-qt6-multimedia
Closed

Fix crash when PyQt6 modules are partially installed#1170
Copilot wants to merge 3 commits into
fix_debian_qt6_multimedia_crashfrom
copilot/fix-crash-qt6-multimedia

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 31, 2026

Nagstamon crashes with ModuleNotFoundError when PyQt6.QtCore is available but other PyQt6 modules (QtMultimedia, QtWebEngine, QtSvg) are missing. This occurs on Debian systems where these are separate packages with alternative dependencies.

Changes

Modified Nagstamon/qui/qt.py to check all required PyQt6 modules upfront during Qt version detection:

# Before: Only checked QtCore
try:
    from PyQt6.QtCore import PYQT_VERSION_STR
    QT_FLAVOR = 'PyQt6'
except ImportError:
    # fallback to PyQt5

# After: Check all required modules
try:
    from PyQt6.QtCore import PYQT_VERSION_STR
    from PyQt6.QtMultimedia import QAudioOutput
    from PyQt6.QtWebEngineCore import QWebEnginePage
    from PyQt6.QtWebEngineWidgets import QWebEngineView
    from PyQt6.QtSvg import QSvgRenderer
    from PyQt6.QtSvgWidgets import QSvgWidget
    QT_FLAVOR = 'PyQt6'
except ImportError:
    # fallback to PyQt5

Applied the same logic to the NAGSTAMON_QT_FLAVOR environment variable path with an informative error message when modules are missing.

Impact

  • Prevents crash when PyQt6 is partially installed
  • Falls back to PyQt5 automatically if any PyQt6 module is unavailable
  • Aligns code behavior with existing Debian package alternative dependencies
  • No change in behavior when all modules are properly installed
Original prompt

This section details on the original issue you should resolve

<issue_title>Crash when Python bindings for Qt 6 Multimedia not installed</issue_title>
<issue_description>On Debian stable (bookworm), nagstamon 3.16.2 crashes with the following error:

Traceback (most recent call last):
  File "/usr/bin/nagstamon", line 45, in <module>
    from Nagstamon.QUI import (APP,
  File "/usr/lib/python3/dist-packages/Nagstamon/QUI/__init__.py", line 35, in <module>
    from .qt import *
  File "/usr/lib/python3/dist-packages/Nagstamon/QUI/qt.py", line 209, in <module>
    from PyQt6.QtMultimedia import QAudioOutput, \
ModuleNotFoundError: No module named 'PyQt6.QtMultimedia'

The error can be solved by installing the python3-pyqt6.qtmultimedia package.

I think in Debian-based distros, the nagstamon package should have the python3-pyqt6.qtmultimedia package as a required dependency so it will be installed automatically with nagstamon.</issue_description>

Comments on the Issue (you are @copilot in this section)

@HenriWahl This is an interesting finding - the current package only contains dependencies for python3-pyqt5.qtmultimedia. So it becomes an interesting question, how to provide 2 different package files 🤔 @HenriWahl Every day one learns something new... the Debian package specs actually allow to define different package names depending on availability... so please try the last package when the CI action https://github.com/HenriWahl/Nagstamon/actions/runs/16624487630 was finished. The output is a one-size-fits-it-all-package which I tested on Debian 11 and 12. Depending on Qt6 being available it will be chosen, otherwise Qt5. @HenriWahl Actually these both packages are listed in https://github.com/HenriWahl/Nagstamon/blob/3.17-20250728/build/debian/control. Strange they were not installed. @HenriWahl Well, this sounds sound. I don't know how to easily solve this. It will be in every case a better decision to use Qt6 in regards of resolution, Wayland usage and so on. I would not like to offer 2 Debian packages, one for Qt5 and one for Qt6. Right now the Nagstamon-Qt5-based code does even not offer the web-based login... @HenriWahl I now added compatibility with Qt5 for the new web login feature and also added all needed packages as dependency for Qt5 and Qt6. In theory the latest testing release should work for you now. @HenriWahl I increased compatibility for Qt6 and Qt5 and their dependecies. Can you please check how the latest testing releases do work for you? @HenriWahl @sylvainfaivre Yes, I am astonished anyway that it is possible to depend on multiple different packages replacing each other. But correctly, ther is no further logic possible in it - the package manager is happy if any of the alternatives is installed, regardless of their inner dependencies. So Nagstamon should be that tolerant and switch back to Qt5 if not all Qt6 modules are loadable. This would not make sure all dependencies are installed, because this is the task of the package manager. Maybe it should tell the user that some packages are missing? @HenriWahl Well, I hoped the switch to PyQt6 will finally be finished somewhen so there is no need for a Qt5 version anymore. The idea about the meta-package sounds interesting. Do you have any clue how to realize it?

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 31, 2026 21:17
Co-authored-by: HenriWahl <2835065+HenriWahl@users.noreply.github.com>
Co-authored-by: HenriWahl <2835065+HenriWahl@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix crash in nagstamon due to missing Qt 6 Multimedia dependency Fix crash when PyQt6 modules are partially installed Jan 31, 2026
Copilot AI requested a review from HenriWahl January 31, 2026 21:20
@HenriWahl HenriWahl changed the base branch from master to fix_debian_qt6_multimedia_crash January 31, 2026 21:27
@HenriWahl HenriWahl marked this pull request as ready for review February 1, 2026 00:32
Copilot AI review requested due to automatic review settings February 1, 2026 00:32
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a crash that occurs when PyQt6 modules are partially installed on Debian-based systems, where PyQt6 components are distributed as separate packages with alternative dependencies.

Changes:

  • Added upfront validation of all required PyQt6 modules (QtMultimedia, QtWebEngineCore, QtWebEngineWidgets, QtSvg, QtSvgWidgets) during Qt version detection
  • Implemented automatic fallback to PyQt5 when any PyQt6 module is unavailable in the auto-detection path
  • Added informative error message when NAGSTAMON_QT_FLAVOR environment variable forces PyQt6 but modules are missing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Nagstamon/qui/qt.py
# Check if all required PyQt6 modules are available
# This prevents crashes when PyQt6 is partially installed
from PyQt6.QtMultimedia import QAudioOutput
from PyQt6.QtWebEngineCore import QWebEnginePage
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'QWebEnginePage' is not used.

Suggested change
from PyQt6.QtWebEngineCore import QWebEnginePage

Copilot uses AI. Check for mistakes.
Comment thread Nagstamon/qui/qt.py
# This prevents crashes when PyQt6 is partially installed
from PyQt6.QtMultimedia import QAudioOutput
from PyQt6.QtWebEngineCore import QWebEnginePage
from PyQt6.QtWebEngineWidgets import QWebEngineView
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'QWebEngineView' is not used.

Copilot uses AI. Check for mistakes.
Comment thread Nagstamon/qui/qt.py
from PyQt6.QtMultimedia import QAudioOutput
from PyQt6.QtWebEngineCore import QWebEnginePage
from PyQt6.QtWebEngineWidgets import QWebEngineView
from PyQt6.QtSvg import QSvgRenderer
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'QSvgRenderer' is not used.

Suggested change
from PyQt6.QtSvg import QSvgRenderer

Copilot uses AI. Check for mistakes.
Comment thread Nagstamon/qui/qt.py
from PyQt6.QtWebEngineCore import QWebEnginePage
from PyQt6.QtWebEngineWidgets import QWebEngineView
from PyQt6.QtSvg import QSvgRenderer
from PyQt6.QtSvgWidgets import QSvgWidget
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'QSvgWidget' is not used.

Suggested change
from PyQt6.QtSvgWidgets import QSvgWidget

Copilot uses AI. Check for mistakes.
@HenriWahl HenriWahl deleted the branch fix_debian_qt6_multimedia_crash February 1, 2026 00:37
@HenriWahl HenriWahl closed this Feb 1, 2026
@HenriWahl HenriWahl deleted the copilot/fix-crash-qt6-multimedia branch February 1, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when Python bindings for Qt 6 Multimedia not installed

3 participants