【labelme 踩坑记录-pip库冲突】QObject::moveToThread: Current thread (0xe0771c0) is not the object's thread (0xdddca70).
最近在Ubuntu24下部署Yolo v5时,发现安装标注软件labelme无法正常运行。报错如下
QObject::moveToThread: Current thread (0xe0771c0) is not the object's thread (0xdddca70).
Cannot move to target thread (0xe0771c0)
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/abc/.local/lib/python3.12/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.
已中止 (核心已转储)
从报错信息来看,是qt和opencv发生冲突。因此我们需要将labelme安装在虚拟环境中启动运行。
创建venv虚拟环境可以查看这篇官方文档
venv环境下安装labelme
在工程文件夹下执行以下操作:
python3 -m venv myenv #创建名称为myenv的虚拟环境
source myenv/bin/activate #激活虚拟环境
pip install labelme #虚拟环境下安装库
使用source会激活所创建的虚拟环境,如图在命令行中会显示当前的虚拟环境名称
等待库安装完成后,输入labelme即可打开