PyQt5 不能在 ChromeOS 上运行?
Posted
技术标签:
【中文标题】PyQt5 不能在 ChromeOS 上运行?【英文标题】:PyQt5 cannot run on ChromeOS? 【发布时间】:2021-08-29 22:07:58 【问题描述】:我正在尝试在 chromeOS 上开发一些 pyqt 应用程序。但是,在安装过程中不断出现一些错误。 我尝试了两种方法,首先使用 conda,然后直接安装软件包。 使用conda安装时没有出现错误,但是当我尝试运行时出现了这个错误
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: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
Aborted (core dumped)
后来我也试过直接安装pyqt,但是这次不能安装
$ pip3 install pyqt5
Collecting pyqt5
Downloading https://files.pythonhosted.org/packages/8e/a4/d5e4bf99dd50134c88b95e926d7b81aad2473b47fde5e3e4eac2c69a8942/PyQt5-5.15.4.tar.gz (3.3MB)
100% |████████████████████████████████| 3.3MB 316kB/s
Installing build dependencies ... done
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.7/tokenize.py", line 447, in open
buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-install-erarrdoj/pyqt5/setup.py'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-erarrdoj/pyqt5/
编辑:
我试试QT_DEBUG_PLUGINS=1 python script.py
输出很长,但我猜这部分告诉错误:
QFactoryLoader::QFactoryLoader() checking directory path "/home/$USER/anaconda3/envs/pyqt/bin/platforms" ...
Cannot load library /home/$USER/anaconda3/envs/pyqt/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-util.so.1: cannot open shared object file: No such file or directory)
QLibraryPrivate::loadPlugin failed on "/home/$USER/anaconda3/envs/pyqt/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so" : "Cannot load library /home/$USER/anaconda3/envs/pyqt/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-util.so.1: cannot open shared object file: No such file or directory)"
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: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
Aborted (core dumped)
我尝试通过以下方式解决此问题
$ conda install -c conda-forge xcb-util
但是,还是会出现同样的错误。
QFactoryLoader::QFactoryLoader() checking directory path "/home/$USER/anaconda3/envs/pyqt_env/bin/platforms" ...
Cannot load library /home/$USER/anaconda3/envs/pyqt_env/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-util.so.1: cannot open shared object file: No such file or directory)
QLibraryPrivate::loadPlugin failed on "/home/$USER/anaconda3/envs/pyqt_env/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so" : "Cannot load library /home/$USER/anaconda3/envs/pyqt_env/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-util.so.1: cannot open shared object file: No such file or directory)"
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.
然后我检查了/home/$USER/anaconda3/envs/pyqt_env/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/
中的文件
奇怪的是我才发现
libqeglfs.so libqminimalegl.so libqoffscreen.so libqwayland-egl.so libqwayland-xcomposite-egl.so libqwebgl.so
libqlinuxfb.so libqminimal.so libqvnc.so libqwayland-generic.so libqwayland-xcomposite-glx.so libqxcb.so
我用同样的方法在 Windows 上安装 pyqt,它可以工作。会不会只是 chromeOS 的问题?
结果
ldd /home/$USER/anaconda3/envs/pyqt_env/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so
是:
linux-vdso.so.1 (0x00007ffff18ed000)
libQt5XcbQpa.so.5 => /home/$USER/anaconda3/envs/pyqt_env/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libQt5XcbQpa.so.5 (0x00007c3b4b564000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007c3b4b50e000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007c3b4b452000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007c3b4b234000)
libQt5Gui.so.5 => /home/$USER/anaconda3/envs/pyqt_env/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libQt5Gui.so.5 (0x00007c3b4a903000)
libQt5DBus.so.5 => /home/$USER/anaconda3/envs/pyqt_env/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libQt5DBus.so.5 (0x00007c3b4a675000)
libQt5Core.so.5 => /home/$USER/anaconda3/envs/pyqt_env/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libQt5Core.so.5 (0x00007c3b49e7f000)
libGL.so.1 => /usr/lib/x86_64-linux-gnu/libGL.so.1 (0x00007c3b49deb000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007c3b49dca000)
libX11-xcb.so.1 => /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007c3b49dc5000)
libxcb-icccm.so.4 => /usr/lib/x86_64-linux-gnu/libxcb-icccm.so.4 (0x00007c3b49dbe000)
libxcb-image.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-image.so.0 (0x00007c3b49bb7000)
libxcb-shm.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007c3b49bb2000)
libxcb-util.so.1 => not found
libxcb-keysyms.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-keysyms.so.1 (0x00007c3b499af000)
libxcb-randr.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-randr.so.0 (0x00007c3b4999d000)
libxcb-render-util.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-render-util.so.0 (0x00007c3b49799000)
libxcb-render.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007c3b49788000)
libxcb-shape.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shape.so.0 (0x00007c3b49783000)
libxcb-sync.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-sync.so.1 (0x00007c3b49779000)
libxcb-xfixes.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-xfixes.so.0 (0x00007c3b4976f000)
libxcb-xinerama.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-xinerama.so.0 (0x00007c3b4976a000)
libxcb-xkb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-xkb.so.1 (0x00007c3b4974c000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007c3b49720000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007c3b4950e000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007c3b493cd000)
libxkbcommon-x11.so.0 => /usr/lib/x86_64-linux-gnu/libxkbcommon-x11.so.0 (0x00007c3b493c2000)
libxkbcommon.so.0 => /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0 (0x00007c3b49380000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007c3b4937b000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007c3b491f5000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007c3b49072000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007c3b49058000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007c3b48e97000)
libxcb-util.so.1 => not found
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007c3b48e92000)
libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007c3b48d71000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007c3b48d34000)
libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007c3b48d2b000)
libpng16.so.16 => /usr/lib/x86_64-linux-gnu/libpng16.so.16 (0x00007c3b48cf2000)
libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007c3b48c9f000)
libicui18n.so.56 => /home/$USER/anaconda3/envs/pyqt_env/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libicui18n.so.56 (0x00007c3b48804000)
libicuuc.so.56 => /home/$USER/anaconda3/envs/pyqt_env/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libicuuc.so.56 (0x00007c3b4844c000)
libicudata.so.56 => /home/$USER/anaconda3/envs/pyqt_env/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/../../lib/libicudata.so.56 (0x00007c3b46a69000)
/lib64/ld-linux-x86-64.so.2 (0x00007c3b4bac3000)
libGLX.so.0 => /usr/lib/x86_64-linux-gnu/libGLX.so.0 (0x00007c3b46a35000)
libGLdispatch.so.0 => /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007c3b46978000)
libxcb-util.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-util.so.0 (0x00007c3b4676f000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007c3b4656b000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007c3b46365000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007c3b462f1000)
libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007c3b4624e000)
libbsd.so.0 => /usr/lib/x86_64-linux-gnu/libbsd.so.0 (0x00007c3b46234000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007c3b4622a000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007c3b46202000)
liblz4.so.1 => /usr/lib/x86_64-linux-gnu/liblz4.so.1 (0x00007c3b461e3000)
libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007c3b460c5000)
libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007c3b460a0000)
【问题讨论】:
QT_DEBUG_PLUGINS=1 python script.py
的输出是什么?
从其他人的这个错误来看,听起来你可能安装了多个版本的 Qt。如果可能,您应该确保仅使用系统版本。
@eyllanesc 我试过了,输出显示在编辑中,有什么建议吗?
@HAOLEE 执行conda install -c conda-forge xcb-util
@eyllanesc 重新安装 xcb-util 后,仍然出现同样的错误
【参考方案1】:
感谢@eyllanesc 的帮助。在使用QT_DEBUG_PLUGINS=1
和ldd /home/$USER/anaconda3/envs/pyqt_env/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so
运行我的.py 之后
原来libxcb-util.so.1 => not found
任何 apt install 或 apt update 都不能解决这个问题。 最后我必须从
下载debian包https://packages.debian.org/bullseye/amd64/libxcb-util1/download
并执行sudo dpkg -i *.deb
手动安装。
【讨论】:
以上是关于PyQt5 不能在 ChromeOS 上运行?的主要内容,如果未能解决你的问题,请参考以下文章
python mac上安装pyqt5后不能正常使用 有大神帮忙看一下吗 如何解决 搞了好久了