|
环境: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))
|
|