labelme icon indicating copy to clipboard operation
labelme copied to clipboard

[BUG] labelme crashes on polygon label assign (qt error)

Open Dimfred opened this issue 5 years ago • 3 comments

Describe the bug Error message after a label has been assigned to a created polygon.

$ labelme --labels semseg_labels.txt .  
<create polygon>
<assign label>
[INFO   ] __init__:get_config:70 - Loading config file from: /home/dimfred/.labelmerc
Traceback (most recent call last):                                                   
  File "/usr/lib/python3.8/site-packages/labelme/widgets/label_list_widget.py", line 46, in paint
    textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)                         
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments  
[1]    33391 abort (core dumped)  labelme --labels semseg_labels.txt .        

To Reproduce Steps to reproduce the behavior:

  1. labelme --labels label.txt .
  2. create polygon
  3. assign label
  4. see error

Desktop (please complete the following information):

  • OS: Manjaro 20.2
  • Labelme Version 4.5.6
  • qt5-base Version: 5.15.2-1
  • python3.8
  • PyQt5 Version: 5.15

Additional context Behaviour is the same whether labelme is installed through AUR or through pip.

Possible resolutions

Install lower pyqt5 lib to resolve error.

# breaks some other libs, but at least labelme works
# assumes that current pyqt5 is not installed in the user space
pip3 install --user pyqt5==5.10

Dimfred avatar Dec 03 '20 15:12 Dimfred

I too face the same problem on Arch linux

sydfouzan avatar Mar 17 '21 10:03 sydfouzan

A solution to a similar issue in another project is found here: https://github.com/spyder-ide/spyder/pull/10215/commits/240e69b43fb32b9b10ea21b0e45d2a137683ed0b.

Simply changing textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options) to textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options, None) at line 46 solved the problem for me.

kongaskristjan avatar May 31 '21 12:05 kongaskristjan

I cannot reproduce anymore with

% python --version
Python 3.10.9

% pip freeze | grep -i pyqt
PyQt5==5.15.9
PyQt5-Qt==5.15.2
PyQt5-Qt5==5.15.2
PyQt5-sip==12.11.1

wkentaro avatar Apr 05 '23 14:04 wkentaro