Loading

【labelimg 闪退 - float 格式错误】

解决办法:

1.将canvas.py文件 526、530、531行的float改为int。

2.在报错文件labelImg.py第965行将float改为int。

具体办法:

一、更改canvas.py文件

文件地址: python-310\Lib\site-packages\libs\canvas.py

第526行

p.drawRect(left_top.x(), left_top.y(), rect_width), int(rect_height)

改为

p.drawRect(int(left_top.x()), int(left_top.y()), int(rect_width), int(rect_height))

第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()))

第531行

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()))

二、更改labelImg.py文件

文件地址:myenv/lib/python3.12/site-packages/labelImg/labelImg.py

第965行

bar.setValue(bar.value() + bar.singleStep() * units)

改为

bar.setValue(int(bar.value() + bar.singleStep() * units))

posted @ 2025-04-15 23:46  CIOZ  阅读(831)  评论(0)    收藏  举报