我正在为我的开发设置一个python3虚拟环境,所以我将远离包管理器apt-install。
$ python3 -m venv . # create my environment in my working directory然后我启动了venv并安装了pyqt5。
$ source bin/activate
$ pip install PyQt5我收到了成功安装的通知,PyQt5和PyQt5 5-Sip出现在我的pip列表中。
当我构建一个示例应用程序时,我会收到以下错误:
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/path/to/venv/lib/python3.8/site-packages/PyQt5/Qt/plugins" 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, webgl, xcb.
Aborted (core dumped)我导出了环境变量以进行调试。
export QT_DEBUG_PLUGINS=1我尝试再次运行我的应用程序,下面是我在链接器中得到的具体错误
QFactoryLoader::QFactoryLoader() looking at "/path/to/venv/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so"
Found metadata in lib /path/to/venv/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"xcb"
]
},
"archreq": 0,
"className": "QXcbIntegrationPlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ...
Cannot load library /path/to/venv/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: cannot open shared object file: No such file or directory)这里最重要的错误是
libxcb-xinerama.so.0: cannot open shared object file: No such file or directory所以我挖得更深了。我决定使用ldd命令来解析共享库依赖项。
$ ldd /path/to/venv/lib/python3.8/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so瞧--瞧:
libxcb-xinerama.so.0 => not found
libxcb-xinerama.so.0 => not found在libqxcb共享库依赖项列表中缺少这些共享库。我希望pip的安装会包括这个,但它不是。我在任何地方都没有找到这个问题的解决方案,而且我已经找到了一些使用apt-install来解决这些问题的资源。我不想改变我的系统,我更喜欢保持沙箱。
我能做些什么来解决这种依赖呢?
发布于 2021-10-12 10:55:14
同样的问题发生在我在Ubuntu20.04上安装pyqt5和matplotlib时,使用的是pipenv (这也创建了一个venv)。
在我的系统中,通过安装缺少的libxcb-xinerama0,使用apt轻松地解决了这一问题:
sudo apt install libxcb-xinerama0发布于 2021-03-23 03:59:36
我在Ubuntu18.04.3上遇到了同样的问题。以下是我解决这个问题的方法。
使用PyQt卸载pip3
pip3 uninstall pyqt5并通过apt-get安装
sudo apt-get install python3-pyqt5发布于 2020-12-10 02:44:32
我也没找到他们。我认为您要么从源代码(https://xorg.freedesktop.org/archive/individual/lib/libxcb-1.14.tar.xz)编译它并链接到它,要么安装libxcb-xinerama0。
https://askubuntu.com/questions/1298645
复制相似问题