Could not load the Qt platform plugin "xcb" in "" even though it was found
-
Hi,
I have a PyQt6 application that uses sqlachemy to connect to a MariaDB server. This app runs correctly under Fedora 38.
I want to dockerize this app but I am new to docker and don't yet master it thus be indulgent for my mistakes.To be as close as possible to my development context I started with a Fedora 38 image on which I installed python3 and the required dependencies.
Here is my Dockerfile for the app
FROM fedora:38 ENV DISPLAY=:0 COPY . . RUN dnf -y upgrade RUN dnf -y install python3 python3-pip RUN python3 -m pip install -r dependencies.txt RUN dnf install -y mesa-libGLU libxkbcommon mesa-libEGL fontconfig dbus-libs xauth CMD [ "python3", "main.py" ]
The dependencies comes from my developement virtual env after I ran the following command
pip freeze > dependencies.txt
attrs==23.1.0
blivet==3.7.1
greenlet==3.0.0a1
jsonpickle==3.0.1
jsonschema==4.17.3
PyMySQL==1.1.0
PyQt5-sip==12.12.1
PyQt6==6.5.1
PyQt6-Qt6==6.5.1
PyQt6-sip==13.5.1
pyrsistent==0.19.3
pyudev==0.24.1
six==1.16.0
SQLAlchemy==1.4.46
SQLAlchemy-Utils==0.39.0
typing_extensions==4.7.0rc1and my docker-compose.yml
version: "3" services: db: container_name: mydb2 image: mariadb:latest ports: - "32001:3306" environment: MYSQL_ROOT_PASSWORD: root app: container_name: biere links: - "db" build: ./ environment: - DISPLAY=${DISPLAY} volumes: - /tmp/.X11-unix:/tmp/.X11-unix ports: - "5001:5000"
connection to the database is provided in this file
from sqlalchemy import create_engine from sqlalchemy_utils import create_database, database_exists from sqlalchemy.orm import sessionmaker, scoped_session from database.orm_base import Base db_url="mysql+pymysql://root:root@mydb2:3306/a_db" if not database_exists(db_url): create_database(db_url) engine = create_engine(db_url,pool_size=5,pool_recycle=3600) Session =sessionmaker(bind=engine,expire_on_commit=False) session =Session()
Then what happens
There is no problem signaled with the build command
sudo docker-compose build
but the command
sudo docker-compose up
returns this message
Starting mydb2 ... done
Starting biere ... done
Attaching to mydb2, biere
mydb2 | 2023-06-30 09:31:05+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.0.2+maria~ubu2204 started.
mydb2 | 2023-06-30 09:31:05+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mydb2 | 2023-06-30 09:31:05+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.0.2+maria~ubu2204 started.
mydb2 | 2023-06-30 09:31:06+00:00 [Note] [Entrypoint]: MariaDB upgrade not required
mydb2 | 2023-06-30 9:31:06 0 [Note] Starting MariaDB 11.0.2-MariaDB-1:11.0.2+maria~ubu2204 source revision 0005f2f06c8e1aea4915887decad67885108a929 as process 1
mydb2 | 2023-06-30 9:31:06 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
mydb2 | 2023-06-30 9:31:06 0 [Note] InnoDB: Number of transaction pools: 1
mydb2 | 2023-06-30 9:31:06 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
mydb2 | 2023-06-30 9:31:06 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
mydb2 | 2023-06-30 9:31:06 0 [Note] InnoDB: Using liburing
mydb2 | 2023-06-30 9:31:06 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
mydb2 | 2023-06-30 9:31:06 0 [Note] InnoDB: Completed initialization of buffer pool
mydb2 | 2023-06-30 9:31:06 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
mydb2 | 2023-06-30 9:31:06 0 [Note] InnoDB: Opened 3 undo tablespaces
mydb2 | 2023-06-30 9:31:06 0 [Note] InnoDB: 128 rollback segments in 3 undo tablespaces are active.
mydb2 | 2023-06-30 9:31:06 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
mydb2 | 2023-06-30 9:31:06 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
mydb2 | 2023-06-30 9:31:06 0 [Note] InnoDB: log sequence number 47641; transaction id 16
mydb2 | 2023-06-30 9:31:06 0 [Note] Plugin 'FEEDBACK' is disabled.
mydb2 | 2023-06-30 9:31:06 0 [Note] Plugin 'wsrep-provider' is disabled.
mydb2 | 2023-06-30 9:31:06 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
mydb2 | 2023-06-30 9:31:06 0 [Note] InnoDB: Buffer pool(s) load completed at 230630 9:31:06
mydb2 | 2023-06-30 9:31:06 0 [Note] Server socket created on IP: '0.0.0.0'.
mydb2 | 2023-06-30 9:31:06 0 [Note] Server socket created on IP: '::'.
mydb2 | 2023-06-30 9:31:06 0 [Note] mariadbd: ready for connections.
mydb2 | Version: '11.0.2-MariaDB-1:11.0.2+maria~ubu2204' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
biere | qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
biere | This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
biere |
biere | Available platform plugins are: vnc, minimal, wayland, minimalegl, linuxfb, offscreen, wayland-egl, vkkhrdisplay, xcb, eglfs.
biere |
mydb2 | 2023-06-30 9:31:08 5 [Warning] Aborted connection 5 to db: 'a_db' user: 'root' host: '172.19.0.3' (Got an error reading communication packets)
biere exited with code 139How to fix this?
-
@jaaf said in Could not load the Qt platform plugin "xcb" in "" even though it was found:
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
The usual way to debug this is to set environment variable
QT_DEBUG_PLUGINS
to1
and then run your program/script. It should produce diagnostic output for the failure. -
Thank you for caring about my problem
I added- QT_DEBUG_PLUGINS=1
in the docker-compose environment for the app
Here is the part of the message I get now.
qt.core.plugin.factoryloader: Got keys from plugin meta data QList("eglfs")
biere | qt.core.plugin.factoryloader: checking directory path "/usr/bin/platforms" ...
biere | qt.core.library: "/usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqxcb.so" cannot load: Cannot load library /usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)
biere | qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqxcb.so" : "Cannot load library /usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)"
biere | qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
biere | This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
It seems that libqxcb.so is missing but I didn't find how to get it.
In the container I installed PyQt6 and PyQt6-Qt6 with pip - QT_DEBUG_PLUGINS=1
-
@jaaf said in Could not load the Qt platform plugin "xcb" in "" even though it was found:
It seems that libqxcb.so is missing but I didn't find how to get it.
biere | qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqxcb.so" : "Cannot load library /usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)"
Well, no, the message tells you that file was found but it has a dependent file
libxkbcommon-x11.so.0
and that does not exist. If you wish to verify this you can runldd /usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqxcb.so
and you should find it will tell you that (along with any other missing dependencies).One normally installs these in the system area via
apt
. I don't know whether you need to do the same or whether this is supposed to be in the supplied PyQt6 plugins directory. Note that it is an X11 package file, that may make a difference to how you are supposed to get it, maybe supplied PyQt6 stuff never includes such. -
OK, thanks. My mistake!
My last docker-compose is now this oneversion: "3" volumes: data: services: db: container_name: mydb2 image: mariadb:latest ports: - "32001:3306" environment: MYSQL_ROOT_PASSWORD: root MYSQL_USER: root volumes: - data:/var/lib/mysql app: container_name: biere links: - "db" build: ./ environment: - DISPLAY=${DISPLAY} - QT_DEBUG_PLUGINS=1 volumes: - /tmp/.X11-unix:/tmp/.X11-unix ports: - "5001:5000"
It seems that there is no longer errors but nothing shows up on the screen.
Here is the output of the docker-compose run command(venvbase) [jaaf@fedora project]$ sudo docker-compose up -d
[sudo] Mot de passe de jaaf :
Creating network "project_default" with the default driver
Creating volume "project_data" with default driver
Pulling db (mariadb:latest)...
latest: Pulling from library/mariadb
3f94e4e483ea: Pull complete
302c1621580e: Pull complete
e9ebb34cbdd0: Pull complete
58c98f01d4c3: Pull complete
a41d8a26ca52: Pull complete
24b0629eb07f: Pull complete
cec8c791723c: Pull complete
a6992c60d007: Pull complete
Digest: sha256:c9520bf76a3cdad4779d65bae4c6c46278283a7212511d99a06c90480d42efb4
Status: Downloaded newer image for mariadb:latest
Creating mydb2 ... done
Creating biere ... done
(venvbase) [jaaf@fedora project]$What is missing ?
-
when I run the command without -d
[jaaf@fedora project]$ docker-compose up
Creating network "project_default" with the default driver
Creating mydb2 ... done
Creating biere ... done
Attaching to mydb2, biere
mydb2 | 2023-06-30 14:59:51+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.0.2+maria~ubu2204 started.
mydb2 | 2023-06-30 14:59:52+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mydb2 | 2023-06-30 14:59:52+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.0.2+maria~ubu2204 started.
mydb2 | 2023-06-30 14:59:52+00:00 [Note] [Entrypoint]: MariaDB upgrade not required
mydb2 | 2023-06-30 14:59:52 0 [Note] Starting MariaDB 11.0.2-MariaDB-1:11.0.2+maria~ubu2204 source revision 0005f2f06c8e1aea4915887decad67885108a929 as process 1
mydb2 | 2023-06-30 14:59:52 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
mydb2 | 2023-06-30 14:59:52 0 [Note] InnoDB: Number of transaction pools: 1
mydb2 | 2023-06-30 14:59:52 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
mydb2 | 2023-06-30 14:59:52 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
mydb2 | 2023-06-30 14:59:52 0 [Note] InnoDB: Using liburing
mydb2 | 2023-06-30 14:59:52 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
mydb2 | 2023-06-30 14:59:52 0 [Note] InnoDB: Completed initialization of buffer pool
mydb2 | 2023-06-30 14:59:52 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
mydb2 | 2023-06-30 14:59:52 0 [Note] InnoDB: Opened 3 undo tablespaces
mydb2 | 2023-06-30 14:59:52 0 [Note] InnoDB: 128 rollback segments in 3 undo tablespaces are active.
mydb2 | 2023-06-30 14:59:52 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
mydb2 | 2023-06-30 14:59:52 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
mydb2 | 2023-06-30 14:59:52 0 [Note] InnoDB: log sequence number 146494; transaction id 92
mydb2 | 2023-06-30 14:59:52 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
mydb2 | 2023-06-30 14:59:52 0 [Note] Plugin 'FEEDBACK' is disabled.
mydb2 | 2023-06-30 14:59:52 0 [Note] Plugin 'wsrep-provider' is disabled.
mydb2 | 2023-06-30 14:59:52 0 [Note] Server socket created on IP: '0.0.0.0'.
mydb2 | 2023-06-30 14:59:52 0 [Note] Server socket created on IP: '::'.
mydb2 | 2023-06-30 14:59:52 0 [Note] InnoDB: Buffer pool(s) load completed at 230630 14:59:52
mydb2 | 2023-06-30 14:59:52 0 [Note] mariadbd: ready for connections.
mydb2 | Version: '11.0.2-MariaDB-1:11.0.2+maria~ubu2204' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
biere | qt.core.plugin.factoryloader: checking directory path "/usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms" ...
biere | qt.core.plugin.factoryloader: looking at "/usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqvnc.so"
biere | qt.core.plugin.loader: Found metadata in lib /usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqvnc.so, metadata=
biere | {
biere | "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
biere | "MetaData": {
biere | "Keys": [
biere | "vnc"
biere | ]
biere | },
biere | "archlevel": 1,
biere | "className": "QVncIntegrationPlugin",
biere | "debug": false,
biere | "version": 394496
biere | }
biere |
biere |
biere | qt.core.plugin.factoryloader: Got keys from plugin meta data QList("vnc")
biere | qt.core.plugin.factoryloader: looking at "/usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqminimal.so"
biere | qt.core.plugin.loader: Found metadata in lib /usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqminimal.so, metadata=
biere | {
biere | "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
biere | "MetaData": {
biere | "Keys": [
biere | "minimal"
biere | ]
biere | },
biere | "archlevel": 1,
biere | "className": "QMinimalIntegrationPlugin",
biere | "debug": false,
biere | "version": 394496
biere | }
biere |
biere |
biere | qt.core.plugin.factoryloader: Got keys from plugin meta data QList("minimal")
biere | qt.core.plugin.factoryloader: looking at "/usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqwayland-generic.so"
biere | qt.core.plugin.loader: Found metadata in lib /usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqwayland-generic.so, metadata=
biere | {
biere | "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
biere | "MetaData": {
biere | "Keys": [
biere | "wayland"
biere | ]
biere | },
biere | "archlevel": 1,
biere | "className": "QWaylandIntegrationPlugin",
biere | "debug": false,
biere | "version": 394496
biere | }
biere |
biere |
biere | qt.core.plugin.factoryloader: Got keys from plugin meta data QList("wayland")
biere | qt.core.plugin.factoryloader: looking at "/usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqminimalegl.so"
biere | qt.core.plugin.loader: Found metadata in lib /usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqminimalegl.so, metadata=
biere | {
biere | "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
biere | "MetaData": {
biere | "Keys": [
biere | "minimalegl"
biere | ]
biere | },
biere | "archlevel": 1,
biere | "className": "QMinimalEglIntegrationPlugin",
biere | "debug": false,
biere | "version": 394496
biere | }
biere |
biere |
biere | qt.core.plugin.factoryloader: Got keys from plugin meta data QList("minimalegl")
biere | qt.core.plugin.factoryloader: looking at "/usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqlinuxfb.so"
biere | qt.core.plugin.loader: Found metadata in lib /usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqlinuxfb.so, metadata=
biere | {
biere | "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
biere | "MetaData": {
biere | "Keys": [
biere | "linuxfb"
biere | ]
biere | },
biere | "archlevel": 1,
biere | "className": "QLinuxFbIntegrationPlugin",
biere | "debug": false,
biere | "version": 394496
biere | }
biere |
biere |
biere | qt.core.plugin.factoryloader: Got keys from plugin meta data QList("linuxfb")
biere | qt.core.plugin.factoryloader: looking at "/usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqoffscreen.so"
biere | qt.core.plugin.loader: Found metadata in lib /usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqoffscreen.so, metadata=
biere | {
biere | "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
biere | "MetaData": {
biere | "Keys": [
biere | "offscreen"
biere | ]
biere | },
biere | "archlevel": 1,
biere | "className": "QOffscreenIntegrationPlugin",
biere | "debug": false,
biere | "version": 394496
biere | }
biere |
biere |
biere | qt.core.plugin.factoryloader: Got keys from plugin meta data QList("offscreen")
biere | qt.core.plugin.factoryloader: looking at "/usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqwayland-egl.so"
biere | qt.core.plugin.loader: Found metadata in lib /usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqwayland-egl.so, metadata=
biere | {
biere | "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
biere | "MetaData": {
biere | "Keys": [
biere | "wayland-egl"
biere | ]
biere | },
biere | "archlevel": 1,
biere | "className": "QWaylandEglPlatformIntegrationPlugin",
biere | "debug": false,
biere | "version": 394496
biere | }
biere |
biere |
biere | qt.core.plugin.factoryloader: Got keys from plugin meta data QList("wayland-egl")
biere | qt.core.plugin.factoryloader: looking at "/usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqvkkhrdisplay.so"
biere | qt.core.plugin.loader: Found metadata in lib /usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqvkkhrdisplay.so, metadata=
biere | {
biere | "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
biere | "MetaData": {
biere | "Keys": [
biere | "vkkhrdisplay"
biere | ]
biere | },
biere | "archlevel": 1,
biere | "className": "QVkKhrDisplayIntegrationPlugin",
biere | "debug": false,
biere | "version": 394496
biere | }
biere |
biere |
biere | qt.core.plugin.factoryloader: Got keys from plugin meta data QList("vkkhrdisplay")
biere | qt.core.plugin.factoryloader: looking at "/usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqxcb.so"
biere | qt.core.plugin.loader: Found metadata in lib /usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqxcb.so, metadata=
biere | {
biere | "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
biere | "MetaData": {
biere | "Keys": [
biere | "xcb"
biere | ]
biere | },
biere | "archlevel": 1,
biere | "className": "QXcbIntegrationPlugin",
biere | "debug": false,
biere | "version": 394496
biere | }
biere |
biere |
biere | qt.core.plugin.factoryloader: Got keys from plugin meta data QList("xcb")
biere | qt.core.plugin.factoryloader: looking at "/usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqeglfs.so"
biere | qt.core.plugin.loader: Found metadata in lib /usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqeglfs.so, metadata=
biere | {
biere | "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
biere | "MetaData": {
biere | "Keys": [
biere | "eglfs"
biere | ]
biere | },
biere | "archlevel": 1,
biere | "className": "QEglFSIntegrationPlugin",
biere | "debug": false,
biere | "version": 394496
biere | }
biere |
biere |
biere | qt.core.plugin.factoryloader: Got keys from plugin meta data QList("eglfs")
biere | qt.core.plugin.factoryloader: checking directory path "/usr/bin/platforms" ...
biere | qt.core.library: "/usr/local/lib64/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqxcb.so" loaded library
biere | Authorization required, but no authorization protocol specified
biere | qt.qpa.xcb: could not connect to display :0
biere | qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
biere | This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
biere |
biere | Available platform plugins are: vnc, minimal, wayland, minimalegl, linuxfb, offscreen, wayland-egl, vkkhrdisplay, xcb, eglfs.
biere |
mydb2 | 2023-06-30 14:59:53 4 [Warning] Aborted connection 4 to db: 'a_db' user: 'root' host: '192.168.32.3' (Got an error reading communication packets)
biere exited with code 139I don't clearly understand the sentence
Authorization required, but no authorization protocol specified
biere | qt.qpa.xcb: could not connect to display :0What shoul I do? . For information, my system run X11, not wayland.