When use multi version of python qt.qpa.plugin: Could not load the Qt platform plugin "xcb"

I use autokey which need python3.11 below. But default of the python version is 3.12.
So I install python3.11 by pyenv.
Commands:

  • pyenv virtualenv 3.11.9 atkenv
  • after install 3.11.9 I activate the env.
    Then I install and run the autokey, but get error like.

QLibraryPrivate::loadPlugin failed on "/usr/lib/qt/plugins/platforms/libqxcb.so"

  • The file /usr/lib/qt/plugins/platforms/libqxcb.so is exist.
  • And I try under the default env and works fine. I said below

I add the QT_DEBUG_PLUGINS flag

the error msg is :

Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/home/lizhe/.pyenv/versions/3.11.9/bin/platforms" ...
Cannot load library /usr/lib/qt/plugins/platforms/libqxcb.so: (/usr/lib/libQt5XcbQpa.so.5: undefined symbol: _ZTI23QPlatformVulkanInstance, version Qt_5_PRIVATE_API)
QLibraryPrivate::loadPlugin failed on "/usr/lib/qt/plugins/platforms/libqxcb.so" : "Cannot load library /usr/lib/qt/plugins/platforms/libqxcb.so: (/usr/lib/libQt5XcbQpa.so.5: undefined symbol: _ZTI23QPlatformVulkanInstance, version Qt_5_PRIVATE_API)"
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb, webgl.

fish: Job 1, 'python test.py' terminated by signal SIGABRT (Abort)

I try a simple pyqt code like:

import sys
from PyQt5.QtWidgets import QApplication, QWidget

def main():
    app = QApplication(sys.argv)
    window = QWidget()
    window.show()
    sys.exit(app.exec_())

if __name__ == "__main__":
    main()

I works fine in the default python. But same error when activate python 3.11.9

The answer on the google not same with mine. Since I installed another version of python and the default one works fine.

I use fish shell I set some global env variable like:

set -gx QT_PLUGIN_PATH /usr/lib/qt/plugins
set -gx QT_QPA_PLATFORM xcb
set -gx LD_LIBRARY_PATH /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms $LD_LIBRARY_PATH

So where should I start to solve this issue?

How did you come to that conclusion?

I just build autokey-qt and it launches without any issues on the default system python.

I get this error when run autokey-qt

> autokey-qt
Traceback (most recent call last):
  File "/usr/bin/autokey-qt", line 5, in <module>
    from autokey.qtui.__main__ import Application
  File "/usr/lib/python3.12/site-packages/autokey/qtui/__main__.py", line 23, in <module>
    from autokey.qtapp import Application
  File "/usr/lib/python3.12/site-packages/autokey/qtapp.py", line 35, in <module>
    from autokey import service, monitor
  File "/usr/lib/python3.12/site-packages/autokey/monitor.py", line 23, in <module>
    from pyinotify import WatchManager, Notifier, EventsCodes, ProcessEvent
  File "/home/lizhe/.local/lib/python3.12/site-packages/pyinotify.py", line 71, in <module>
    import asyncore
ModuleNotFoundError: No module named 'asyncore'

Asyncore is removed base on this

I just installed autokey-qt and no problems on my side :slight_smile:

I think your problem is here

Look like autokey is trying to look for some locally installed module (old version?), probably installed via pip. Don’t use pip outside virtualenv because this can break your system :wink:

1 Like

I remove the pyinotify package and it works fine.
But if there is no pyinotify package what is autokey using now?

Uses package from repositories - python-pyinotify

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.