One alternative is to use Qt.py, it wraps PySide6, PyQt6, PySide2, PyQt5 under one interface. Qt.py is a single file so it is easy to add to existing package, and then all imports must be replaced to use it. Note that it uses PySide6 names instead of PyQt5.
example:
from Qt.QtCore import (
Qt,
QObject,
Slot, # note: not pyqtSlot !
Signal, # note: not pyqtSignal !
Property) # note: not pyqtProperty !
from Qt.QtGui import (
QColor,
QPalette)
from Qt.QtWidgets import (
QApplication,
QWidget)
import krita
try:
if int(krita.qVersion().split('.')[0]) == 5:
raise
from PyQt6.QtCore import *
from PyQt6.QtGui import *
except:
from PyQt5.QtCore import *
from PyQt5.QtGui import *
Import error isn’t good enough sometimes if you have both Qt5 and Qt6 on a system since Qt5 will import fine without erroring.