2

我有一个使用 Qt5(通过 PyQt)运行的应用程序。我正在使用 miniconda,python 代码已经过 cythonized。该代码是在我的本地机器上设置的,从原始.py文件生成的 cython 代码以及安装在 miniconda 中的相关库和模块,以便代码成功运行。然后我将所有内容都发送到另一台机器上,编译 cython 代码以提供.so文件并尝试运行它。此时我得到错误:

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)

我已经四处寻找可能的解决方案很长时间了,我有以下额外信息:

我已经检查了各种.so文件的 ldd 。似乎都找到了所需的库。

我已经尝试过locate libqxcb.so,这会返回: ~/miniconda3/pkgs/qt-5.6.2-3/plugins/platforms/libqxcb.so & ~/miniconda3/plugins/platforms/libqxcb.so

根据 TranslucentCloud 的建议我已将其复制到目录~/miniconda3/bin/platforms(新创建的)。

我还包含export QT_DEBUG_PLUGINS=1在调用我的代码的脚本中。这给出了以下输出:

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"

GUI 现在加载和按钮等工作。但是,仍然存在一些问题 - 小问题是所有字体都与我的本地机器不同(不是主要问题,但可能表明它仍然没有找到一些相关的库)。

更严重的是,GUI 不响应任何按键 - GUI 有很多文本框要填写,所以这使它无法使用。

显然,上面的输出中仍然存在一些错误,但是,尚不清楚哪些库等仍然无法找到(或为什么会这样)。

4

1 回答 1

4

解决上述错误需要一些步骤:

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)

这可以通过复制~/miniconda3/plugins/platforms来解决~/miniconda3/bin

此外,在启动 Qt GUI 的 bash 脚本中,我添加了以下几行,否则 GUI 中的所有文本都会出现在 Courier 中:

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

最后,我还需要以下行来允许 GUI 注册按键:

export QT_XKB_CONFIG_ROOT=/usr/share/X11/xkb

解决这个问题的关键是这条线: export QT_DEBUG_PLUGINS=1它使我能够看到 Qt 出现问题的地方。

于 2017-03-30T15:43:03.607 回答