labelimg点击框选图片就闪退报错的解决办法(不一定具有普适性)

文章讲述了在使用Python3.10时遇到的一个类型错误,具体涉及libs/canvas.py文件中的drawLine函数。错误因参数类型为float而非int引起。解决方案包括将Python版本回退到3.9或直接修改canvas.py文件中的相关行,将float类型改为int。作者提供了解决问题后的个人体验,但提示这可能不适用于所有情况。
摘要由CSDN通过智能技术生成

报错:

Traceback (most recent call last):
  File "C:\Users\86186\AppData\Local\Programs\Python\Python310\lib\site-packages\libs\canvas.py", line 530, in paintEvent
    p.drawLine(self.prev_point.x(), 0, self.prev_point.x(), self.pixmap.height())
TypeError: arguments did not match any overloaded call:
  drawLine(self, l: QLineF): argument 1 has unexpected type 'float'
  drawLine(self, line: QLine): argument 1 has unexpected type 'float'
  drawLine(self, x1: int, y1: int, x2: int, y2: int): argument 1 has unexpected type 'float'
  drawLine(self, p1: QPoint, p2: QPoint): argument 1 has unexpected type 'float'
  drawLine(self, p1: Union[QPointF, QPoint], p2: Union[QPointF, QPoint]): argument 1 has unexpected type 'float'

解决方法:

1、将python版本退回3.9

Win 10 环境:Pycharm、anaconda、python3.10

注:anaconda下载及配置环境变量参考:

(6条消息) Anaconda超详细安装教程(Windows环境下)_windows安装conda_菜鸟1号!!的博客-CSDN博客


1)、打开cmd
2)、执行下列命令
conda install python==3.9
3)、查看python版本,是否降版本成功
python --version 或 python -V

参考链接:(6条消息) [Win 10]Python降版本方法、Python3.9降至3.7_Bouble Q的博客-CSDN博客

2、将canvas.py文件 526、530、531行的float改为int。(找不到文件的话,直接搜索就行)

改前:

改后:

参考链接:

Unable to draw annotations on Windows · Issue #811 · heartexlabs/labelImg · GitHub

我改完以后即可正常框选,不过不一定适用你们的情况~~~

评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值