PYQT5:此应用程序无法启动,因为无法初始化QT平台插件 - 安装问题?
我正在研究Ubuntu 18.04(作为Linux的Windows 10子系统)。 当我尝试运行使用PYQT5的代码时,它会引发错误:
” qt.qta.xcb:无法连接到显示
qt.qpa.plugin:即使找到了QT平台插件“ XCB”,即使找到了QT平台插件。 由于无法初始化QT平台插件,因此该应用程序无法启动。重新安装应用程序可能会解决此问题。
可用的平台插件是:EGLFS,LinuxFB,Minimal,Minimalegl,屏幕外,VNC,XCB。
中止 “
如图像错误消息的图像(该错误肯定连接到pyqt5)。 我发现了许多建议:
- 转到=> Python38>lib>site-packages>PyQt5>Qt>plugins
- In plugins copy platforms folder
- After that go to Python38>lib>site-packages>PyQt5_tools>Qt>bin
- paste folder here.请复制并替换。
但是,我的计算机上似乎没有pyqt5_tool中的QT文件夹。 我已经删除并安装了PYQT5,PYQT5-Tools,Pyqt5-Plugins多次,但它不起作用。它可以与我使用子系统的事实联系在一起吗? (我在Windows和Ubuntu上都下载了PYQT5)。有任何解决这个问题的建议吗?
I am working on Ubuntu 18.04 (as a Windows 10 subsystem for linux).
When I try running code that uses pyqt5 it throws the error:
"
qt.qta.xcb: could not connect to display
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, xcb.
Aborted
"
as in the image image of error message (the error is definitely connected to pyqt5).
I have found many posts that suggest to:
- Go to => Python38>lib>site-packages>PyQt5>Qt>plugins
- In plugins copy platforms folder
- After that go to Python38>lib>site-packages>PyQt5_tools>Qt>bin
- paste folder here. Do copy and replace.
but it seems like there is no Qt folder in pyqt5_tools on my computer.
I have removed and installed back pyqt5, pyqt5-tools, pyqt5-plugins several times but it does not work. Can it be connected to the fact that I am using a subsystem? (I have downloaded pyqt5 both on Windows and on Ubuntu). Any suggestions to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
有人建议运行“ Xhost +local:”。
Someone suggested to run "xhost +local:" first.
该错误与一个或多个与XCB相关的库的缺失要求有关,该库需要在X11上实现以使QT正常运行。有关XCB库的完整列表,请检查在这里。
我建议,您首先尝试通过
pip
重新安装PYQT5,而不是复制文件。我在conda
上也有类似的经验,其中pysided2由于缺少shiboken
而无法工作,我必须通过pip
进行安装。另外,您可能需要尝试
conda
(例如Anaconda或Miniconda)。最后但并非最不重要的一点是,如果这是您唯一的问题,则可以尝试安装所需的XCB库。但是,这很棘手,因为您的发行版提供的版本可能与pip
安装的其余版本不同。安装PYQT5的安全方法只是使用WSL内部的发行版本的软件包管理器。由于它是一个虚拟化系统,因此我认为它是仅出于在PYQT5项目上工作的目的而创建的,此后将被删除。安装干净的初始设置,如果不存在问题。
The error relates to a missing requirement for one or multiple XCB-related libraries, which needs to be fulfilled on X11 for Qt to function properly. For a full list of XCB libraries check here.
I would suggest that, instead of copying files left and right, you first try reinstalling PyQt5 via
pip
. I've had a similar experience withconda
, where PySided2 was not working due to a missingshiboken
, which I had to install viapip
.In addition you may want to try
conda
(e.g. Anaconda or Miniconda). Last but not least, if this is the only problem you have, you may attempt to install the required XCB libraries. This is however tricky, since the version your distro provides may be different from the rest that thepip
installation has.A safe way for installing PyQt5 is simply using the package manager of your distro inside WSL. Since it's a virtualized system I'd assume that it's created solely for the purpose of working on a PyQt5 project and after that it will be deleted. Tainting the clean initial setup should therefor not be an issue.
此错误显示,因为您在基本环境上安装了PYQT,因此请删除Anaconda并重新安装它,然后尝试创建一个新的环境并在其中工作。
This error shows because you install PyQt on the base environment, so remove anaconda and reinstall it again then try to create a new environment and work in it.
在我的具体情况下,问题是由WSL引起的,WSL无法访问计算机的图形部分。我在计算机上执行了双重启动以继续进行,因为我找不到解决问题的方法。
In my specific case the issue is caused by the WSL, that has no access to the graphic part of the computer. I performed a dual boot on my computer in order to proceed, because I could not find a way to solve the issue.
我也遇到了同样的问题,WSL上也有Ubuntu 18。
我解决了 @rbaleksandar的建议。
I had the same issue, Ubuntu 18 on WSL as well.
I solved following @rbaleksandar's suggestion.