PYQT5:此应用程序无法启动,因为无法初始化QT平台插件 - 安装问题?

发布于 2025-02-01 18:25:11 字数 817 浏览 4 评论 0原文

我正在研究Ubuntu 18.04(作为Linux的Windows 10子系统)。 当我尝试运行使用PYQT5的代码时,它会引发错误:

” qt.qta.xcb:无法连接到显示

qt.qpa.plugin:即使找到了QT平台插件“ XCB”,即使找到了QT平台插件。 由于无法初始化QT平台插件,因此该应用程序无法启动。重新安装应用程序可能会解决此问题。

可用的平台插件是:EGLFS,LinuxFB,Minimal,Minimalegl,屏幕外,VNC,XCB。

中止 “

如图像错误消息的图像(该错误肯定连接到pyqt5)。 我发现了许多建议:

  1. 转到=> Python38>lib>site-packages>PyQt5>Qt>plugins
  2. In plugins copy platforms folder
  3. After that go to Python38>lib>site-packages>PyQt5_tools>Qt>bin
  4. 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:

  1. Go to => Python38>lib>site-packages>PyQt5>Qt>plugins
  2. In plugins copy platforms folder
  3. After that go to Python38>lib>site-packages>PyQt5_tools>Qt>bin
  4. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

毅然前行 2025-02-08 18:25:11

有人建议运行“ Xhost +local:”。

Someone suggested to run "xhost +local:" first.

才能让你更想念 2025-02-08 18:25:11

该错误与一个或多个与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 with conda, where PySided2 was not working due to a missing shiboken, which I had to install via pip.

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 the pip 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.

白况 2025-02-08 18:25:11

此错误显示,因为您在基本环境上安装了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.

自我难过 2025-02-08 18:25:11

在我的具体情况下,问题是由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.

这样的小城市 2025-02-08 18:25:11

我也遇到了同样的问题,WSL上也有Ubuntu 18。

我解决了 @rbaleksandar的建议。

conda install -c anaconda pyqt

I had the same issue, Ubuntu 18 on WSL as well.

I solved following @rbaleksandar's suggestion.

conda install -c anaconda pyqt
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文