PyQt5 'Qt5.15' Version not found

Hi. I am trying to build a snap of a simple python pyqt5 application. The snapcraft command successfully builds the snap but when I run the pyqt5-test command to run the app I get the following error.

Error that I am facing : https://pastebin.com/aq5fK4jE

Here is my snapcraft.yaml file
Link: https://pastebin.com/aEmfCEg0

Qt 5.15 is not available in core 20 which is based on Ubuntu 20.04, it contains Qt5.12 in repositories. https://packages.ubuntu.com/focal/qt5-default

In order to have Qt5.15 bundled into your snap you have to manually write the deployment steps.

You can add this repo (ppa): https://launchpad.net/~beineri/+archive/ubuntu/opt-qt-5.15.0-focal to your snapcraft build environment and install qt5.15 and required modules as stage-packages from here.

Hi. Thanks for the reply. Yes I Have fixed that issue but now when I am running the pyqt5-test command I am getting this error :

(process:1947): GLib-CRITICAL **: 14:38:34.850: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
[1]    1947 segmentation fault (core dumped)  python

Set QT_DEBUG_PLUGINS env variable with export QT_DEBUG_PLUGINS=1 to obtain diagnostic information from Qt, about each plugin it tries to load, before running your application.

You should open a shell inside you snap container with snap run --shell your_snap_package_name
Then CD $SNAP to go to the snap’s root from there, try to set QT_DEBUG_PLUGINS env variable before running your actual app. Post the output you get after that.

@keshavnrj Hi. Thanks for the reply. Here is the output

Snapcraft file : https://pastebin.com/kw8fZqRe
main.py : https://pastebin.com/rGsueuEP

QFactoryLoader::QFactoryLoader() looking at "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqeglfs.so"
Found metadata in lib /snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqeglfs.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "eglfs"
        ]
    },
    "archreq": 0,
    "className": "QEglFSIntegrationPlugin",
    "debug": false,
    "version": 331264
}


Got keys from plugin meta data ("eglfs")
QFactoryLoader::QFactoryLoader() looking at "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqlinuxfb.so"
Found metadata in lib /snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqlinuxfb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "linuxfb"
        ]
    },
    "archreq": 0,
    "className": "QLinuxFbIntegrationPlugin",
    "debug": false,
    "version": 331264
}


Got keys from plugin meta data ("linuxfb")
QFactoryLoader::QFactoryLoader() looking at "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqminimal.so"
Found metadata in lib /snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqminimal.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "minimal"
        ]
    },
    "archreq": 0,
    "className": "QMinimalIntegrationPlugin",
    "debug": false,
    "version": 331264
}


Got keys from plugin meta data ("minimal")
QFactoryLoader::QFactoryLoader() looking at "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqminimalegl.so"
Found metadata in lib /snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqminimalegl.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "minimalegl"
        ]
    },
    "archreq": 0,
    "className": "QMinimalEglIntegrationPlugin",
    "debug": false,
    "version": 331264
}


Got keys from plugin meta data ("minimalegl")
QFactoryLoader::QFactoryLoader() looking at "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqoffscreen.so"
Found metadata in lib /snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqoffscreen.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "offscreen"
        ]
    },
    "archreq": 0,
    "className": "QOffscreenIntegrationPlugin",
    "debug": false,
    "version": 331264
}


Got keys from plugin meta data ("offscreen")
QFactoryLoader::QFactoryLoader() looking at "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqvnc.so"
Found metadata in lib /snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqvnc.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "vnc"
        ]
    },
    "archreq": 0,
    "className": "QVncIntegrationPlugin",
    "debug": false,
    "version": 331264
}


Got keys from plugin meta data ("vnc")
QFactoryLoader::QFactoryLoader() looking at "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqwayland-egl.so"
Found metadata in lib /snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqwayland-egl.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "wayland-egl"
        ]
    },
    "archreq": 0,
    "className": "QWaylandEglPlatformIntegrationPlugin",
    "debug": false,
    "version": 331264
}


Got keys from plugin meta data ("wayland-egl")
QFactoryLoader::QFactoryLoader() looking at "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqwayland-generic.so"
Found metadata in lib /snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqwayland-generic.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "wayland"
        ]
    },
    "archreq": 0,
    "className": "QWaylandIntegrationPlugin",
    "debug": false,
    "version": 331264
}


Got keys from plugin meta data ("wayland")
QFactoryLoader::QFactoryLoader() looking at "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqwayland-xcomposite-egl.so"
Found metadata in lib /snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqwayland-xcomposite-egl.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "wayland-xcomposite-egl"
        ]
    },
    "archreq": 0,
    "className": "QWaylandXCompositeEglPlatformIntegrationPlugin",
    "debug": false,
    "version": 331264
}


Got keys from plugin meta data ("wayland-xcomposite-egl")
QFactoryLoader::QFactoryLoader() looking at "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqwayland-xcomposite-glx.so"
Found metadata in lib /snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqwayland-xcomposite-glx.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "wayland-xcomposite-glx"
        ]
    },
    "archreq": 0,
    "className": "QWaylandXCompositeGlxPlatformIntegrationPlugin",
    "debug": false,
    "version": 331264
}


Got keys from plugin meta data ("wayland-xcomposite-glx")
QFactoryLoader::QFactoryLoader() looking at "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqwebgl.so"
Found metadata in lib /snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqwebgl.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "webgl"
        ]
    },
    "archreq": 0,
    "className": "QWebGLIntegrationPlugin",
    "debug": false,
    "version": 331264
}


Got keys from plugin meta data ("webgl")
QFactoryLoader::QFactoryLoader() looking at "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so"
Found metadata in lib /snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "xcb"
        ]
    },
    "archreq": 0,
    "className": "QXcbIntegrationPlugin",
    "debug": false,
    "version": 331264
}


Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ...
loaded library "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so"
loaded library "Xcursor"
QFactoryLoader::QFactoryLoader() checking directory path "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platformthemes" ...
QFactoryLoader::QFactoryLoader() looking at "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platformthemes/libqgtk3.so"
Found metadata in lib /snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platformthemes/libqgtk3.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1",
    "MetaData": {
        "Keys": [
            "gtk3"
        ]
    },
    "archreq": 0,
    "className": "QGtk3ThemePlugin",
    "debug": false,
    "version": 331264
}


Got keys from plugin meta data ("gtk3")
QFactoryLoader::QFactoryLoader() looking at "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platformthemes/libqxdgdesktopportal.so"
Found metadata in lib /snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platformthemes/libqxdgdesktopportal.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1",
    "MetaData": {
        "Keys": [
            "xdgdesktopportal",
            "flatpak",
            "snap"
        ]
    },
    "archreq": 0,
    "className": "QXdgDesktopPortalThemePlugin",
    "debug": false,
    "version": 331264
}


Got keys from plugin meta data ("xdgdesktopportal", "flatpak", "snap")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platformthemes" ...
loaded library "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platformthemes/libqxdgdesktopportal.so"
loaded library "/snap/pyqt5-test/x12/lib/python3.8/site-packages/PyQt5/Qt/plugins/platformthemes/libqgtk3.so"

(process:9198): Gtk-WARNING **: 10:42:11.982: Locale not supported by C library.
	Using the fallback 'C' locale.
Gtk-Message: 10:42:12.385: Failed to load module "canberra-gtk-module"
Gtk-Message: 10:42:12.386: Failed to load module "canberra-gtk-module"

(python3:9198): GLib-CRITICAL **: 10:42:12.386: g_hash_table_contains: assertion 'hash_table != NULL' failed

(python3:9198): GLib-CRITICAL **: 10:42:12.386: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
Segmentation fault (core dumped)

The output of plugins loaded by qt looks good,
but looking at your snapcraft.yaml file makes me feel that you are mixing the system’s Qt libraries with the one provided by pip at line no. 38 (PyQt5==5.14.1). You are staging python3-pyqt5(coming from ubuntu system repositories) with your stage-packages definition, and mixing them with the one provided by pip. Remove one them and try build your snap again.

Also why you setting gtk2 as platform theme in env variable?

Does anyone get a solution yet? I’m having the same problem even after compiling with cx_freeze.