找回密码
 会员注册
查看: 32|回复: 0

labelImg之闪退篇

[复制链接]

2万

主题

0

回帖

6万

积分

超级版主

积分
64738
发表于 2024-9-3 21:23:36 | 显示全部楼层 |阅读模式
环境:Ubuntu16.04,python3.10使用pip安装的labelImg点击绘制会发生闪退并报错:Traceback(mostrecentcalllast): File"/python3.10/site-packages/libs/canvas.py",line530,inpaintEvent  p.drawLine(self.prev_point.x(),0,self.prev_point.x(),self.pixmap.height())TypeError:argumentsdidnotmatchanyoverloadedcall: drawLine(self,lLineF):argument1hasunexpectedtype'float' drawLine(self,lineLine):argument1hasunexpectedtype'float' drawLine(self,x1:int,y1:int,x2:int,y2:int):argument1hasunexpectedtype'float' drawLine(self,p1Point,p2Point):argument1hasunexpectedtype'float' drawLine(self,p1:Union[QPointF,QPoint],p2:Union[QPointF,QPoint]):argument1hasunexpectedtype'float'已放弃(核心已转储)原因:python3.8之后绘图函数不允许有非整数。解决1.打开报错提示的canvas.py文件1.1修改526行: p.drawRect(left_top.x(),left_top.y(),rect_width,rect_height)        修改为: p.drawRect(int(left_top.x()),int(left_top.y()),int(rect_width),int(rect_height)) 1.2 530行:p.drawLine(self.prev_point.x(),0,self.prev_point.x(),self.pixmap.height())        修改为:p.drawLine(int(self.prev_point.x()),0,int(self.prev_point.x()),int(self.pixmap.height()))1.3531行: p.drawLine(0,self.prev_point.y(),self.pixmap.width(),self.prev_point.y())        修改为 p.drawLine(0,int(self.prev_point.y()),int(self.pixmap.width()),int(self.prev_point.y()))2.修改python3.10/site-packages/labelImg/labelImg.py        第950行bar.setValue(bar.value()+bar.singleStep()*units)        修改为 bar.setValue(int(bar.value()+bar.singleStep()*units))
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 会员注册

本版积分规则

QQ|手机版|心飞设计-版权所有:微度网络信息技术服务中心 ( 鲁ICP备17032091号-12 )|网站地图

GMT+8, 2024-12-28 20:39 , Processed in 0.489486 second(s), 26 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表