我有一个使用Qt5(通过PyQt)运行的应用程序。我正在使用miniconda,python代码已被cythonised。代码在我的本地机器上设置,cython代码由原始.py
文件和安装在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中的建议here,我已将其复制到目录~/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有许多文本框要填写,因此这使得它无法使用。
上面的输出中仍然存在一些错误,但是,目前还不清楚哪些库等仍然无法找到(或者为什么会出现这种情况)。
答案 0 :(得分:3)
解决上述错误需要采取一些步骤:
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在哪里破碎。