我无法在 NixOS 上使用 PySide6,我尝试从 nixpkgs、pip 和 conda 安装 pyside,但最终得到了相同的结果。我有这个示例文件:
from PySide6.QtWidgets import QApplication, QWidget
# Only needed for access to command line arguments
import sys
# You need one (and only one) QApplication instance per application.
# Pass in sys.argv to allow command line arguments for your app.
# If you know you won't use command line arguments QApplication([]) works too.
app = QApplication(sys.argv)
# Create a Qt widget, which will be our window.
window = QWidget()
window.show() # IMPORTANT!!!!! Windows are hidden by default.
# Start the event loop.
app.exec()
这应该打开一个示例窗口,但我有以下错误:
$ python qt.py
qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
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: vnc, vkkhrdisplay, linuxfb, minimalegl, xcb, eglfs, offscreen, minimal, wayland, wayland-egl.
Aborted (core dumped)
我在网上尝试了其他解决方案,例如从 nixpkgs 安装 xcb-util-cursor,但似乎没有任何帮助。我在 nixpkgs 的不稳定分支上。有没有人能够让 pyside6 在你的 nixos 设置中工作?
这可能不相关,但对于 debian 我必须安装以下软件包:
sudo apt install libxcb-cursor0 libxcb-icccm4 libxcb-keysyms1
ldd venv/lib/python3.11/site-packages/PySide6/Qt/plugins/platforms/libqxcb.so | grep -i "not found"