python报错:Could not load the Qt platform plugin “xcb“ in “./plugins/platforms“的解决方法

本文介绍了一种在使用PyQt5和Matplotlib进行绘图时遇到的错误及其解决办法。该错误涉及Qt平台插件加载失败的问题,并提供了一种通过清理重复PyQt5安装来解决的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • 问题描述

利用matplotlib库画图的时候,报如下错误:

qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “./plugins/platforms” 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.

已放弃 (核心已转储)

  • 解决方法

  1. 尝试删除pyqt5后再重新安装。没解决。

  2. 尝试修改各种路径信息,但是经过确认路径信息都是对的。没解决。

  3. 尝试安装各种依赖。没解决。

  4. 最后!!删除python已安装库中重复的pyqt5,成功!!!具体步骤如下:

    1. (非必须,如果你的环境有用conda隔开的话)conda activate xxx(你的环境名)
    2. pip list (查看PyQt5是否有重复。我这里是同时出现了PyQt5和PyQt5-sip)
    3. (如果确实存在重复的pyqt5)pip uninstall PyQt5

    done!

评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值