【bug记录】Cannot move to target thread (0x24acc50) qt.qpa.plugin: Could not load the Qt platform plugin

1.问题描述

在pycharm中运行程序时,出现如下错误:

QObject::moveToThread: Current thread (0x24acc50) is not the object’s thread (0x4604bb0).
Cannot move to target thread (0x24acc50)
qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “/home/omnisky/miniconda3/envs/rellis/lib/python3.8/site-packages/cv2/qt/plugins” 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: xcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl.

但是在终端运行的话又不会有这个问题。
重要的是程序没法在pycharm中调试,莫名其妙!真的hin烦!!!
在网上搜了一圈,试了很多方法,都是依托答辩。
最终稀里糊涂的解决了,也不知道具体原因出在哪。从最终的效果来看,就是这个傻逼Qt的问题。

不吐槽了。

问题还是出在了mayavimatplotlib这两个库身上,因为使用它们显示时,不可避免的要用到Qt。

import matplotlib.pyplot as plt
import mayavi.mlab as mlab

但具体什么原因,咱也不知道。

2. 解决办法

先卸载通过conda和pip安装的所有qt相关的狗屎,然后重新用pip安装PyQt5,顺便给opencv-python降个版本。

 pip uninstall pyqt
 pip uninstall pyqt5  # 卸载之后,使用mayavi的时候会报错,找不到qt之类的
 pip uninstall PyQt5 PyQt5-sip PyQt5-Qt5
 pip install opencv-python==4.1.2.30
 conda install pyqt
 conda uninstall pyqt  # 别问为什么装了又卸,我也不知道
 pip install PyQt5

别问!问就是玄学!总之解决了!

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值