I think the standard approach has been to initially use a try / except block to initially attempt to import the new module name and if that fails import the old name.
See
Code:
try:
from PyQt5.Qt import QUrl, pyqtSignal, QTimer
from PyQt5.Qt import (QMenu, QModelIndex, QFileDialog, QIcon)
except ImportError:
from PyQt4.Qt import QUrl, pyqtSignal, QTimer
from PyQt4.Qt import (QMenu, QModelIndex, QFileDialog, QIcon)
as an example. (Code from the current Kobo Utilities plugin.)
Sent from my Pixel 7a using Tapatalk