简体   繁体   中英

This application failed to start because it could not find or load the Qt platform plugin "xcb" in ""

I have an application which runs using Qt5 (via PyQt). I am using miniconda and the python code has been cythonised. The code was setup on my local machine, the cython code produced from the original .py files and the relevant libraries and modules installed in miniconda such that the code runs successfully. Then I ship everything to another machine, compile the cython code to give .so files and attempt to run it. At this point I get the error:

This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Reinstalling the application may fix this problem.
Aborted (core dumped)

I have looked around for a long time for possible solutions and I have the following extra information:

I have checked ldd on the various .so files. All seem to find the required libraries.

I have tried locate libqxcb.so and this returns: ~/miniconda3/pkgs/qt-5.6.2-3/plugins/platforms/libqxcb.so & ~/miniconda3/plugins/platforms/libqxcb.so

Based on the suggestions here from TranslucentCloud, I have copied this to the directory ~/miniconda3/bin/platforms (newly created).

I have also included export QT_DEBUG_PLUGINS=1 in the script which calls my code. This gives the following output:

QFactoryLoader::QFactoryLoader() checking directory path "~/miniconda3/bin/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "~/miniconda3/bin/platforms/libqxcb.so"
Found metadata in lib ~/miniconda3/bin/platforms/libqxcb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "xcb"
        ]
    },
    "className": "QXcbIntegrationPlugin",
    "debug": false,
    "version": 329218
}


Got keys from plugin meta data ("xcb")
loaded library "~/miniconda3/bin/platforms/libqxcb.so"
xkbcommon: ERROR: failed to add default include path ~/Programmes/miniconda3/lib
Qt: Failed to create XKB context!
Use QT_XKB_CONFIG_ROOT environmental variable to provide an additional search path, add ':' as separator to provide several search paths and/or make sure that XKB configuration data directory contains recent enough contents, to update please see http://cgit.freedesktop.org/xkeyboard-config/ .
QFactoryLoader::QFactoryLoader() checking directory path "~/miniconda3/bin/xcbglintegrations" ...
QFactoryLoader::QFactoryLoader() checking directory path "~/miniconda3/bin/platformthemes" ...
QFactoryLoader::QFactoryLoader() checking directory path "~/miniconda3/bin/platforminputcontexts" ...
QFactoryLoader::QFactoryLoader() checking directory path "~/miniconda3/bin/styles" ...
Fontconfig error: Cannot load default config file
QFactoryLoader::QFactoryLoader() checking directory path "~/miniconda3/bin/accessible" ...
QFactoryLoader::QFactoryLoader() checking directory path "~/miniconda3/bin/accessiblebridge" ...
QXcbConnection: XCB error: 145 (Unknown), sequence: 165, resource id: 0, major code: 139 (Unknown), minor code: 20
QFactoryLoader::QFactoryLoader() checking directory path "~/miniconda3/bin/imageformats" ...
QLibraryPrivate::unload succeeded on "~/miniconda3/bin/platforms/libqxcb.so"

The GUI now loads and buttons etc work. However, there are still a few issues - the minor issue is that all the fonts are different from my local machine (not a major problem, but presumably indicative that it's still not finding some relevant libraries).

More seriously, the GUI doesn't respond to any key presses - the GUI has lots of text boxes to fill in so this makes it unusable.

There are clearly some errors still in the output above, however, it's not clear from this which libraries etc. it is still unable to find (or why this is the case).

A number of steps were necessary to resolve the errors above:

This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Reinstalling the application may fix this problem.
Aborted (core dumped)

This can be resolved by copying ~/miniconda3/plugins/platforms to ~/miniconda3/bin .

In addition in the bash script which launches the Qt GUI I have added the following lines, otherwise all the text in the GUI appears in Courier:

export FONTCONFIG_FILE=/etc/fonts/fonts.conf
export FONTCONFIG_PATH=/etc/fonts/

Finally I also needed the following line to allow keypresses to be registered by the GUI:

export QT_XKB_CONFIG_ROOT=/usr/share/X11/xkb

Key to resolving this was the line: export QT_DEBUG_PLUGINS=1 which enabled me to see where Qt was breaking.

sudo apt-get install qt5-default

It helped me to open shotcut in ubuntu

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM