labelImg
labelImg copied to clipboard
Unable to draw annotations on Windows
I installed Python 3.10, PyQt5 and libxml using instructions in readme. md
I used pyrcc5 to create resources.qrc successfully.
The UI loads, and I can get to my folder, and see my images. As soon as I try creating an annotation (pressed W on my keyboard) the script crashes with the following log
Traceback (most recent call last):
File "C:\Users\whoever\AppData\Local\Programs\Python\Python310\Apps\labelImg-master\labelImg-master\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, QLineF): argument 1 has unexpected type 'float'
drawLine(self, QLine): argument 1 has unexpected type 'float'
drawLine(self, int, int, int, int): argument 1 has unexpected type 'float'
drawLine(self, QPoint, QPoint): argument 1 has unexpected type 'float'
drawLine(self, Union[QPointF, QPoint], Union[QPointF, QPoint]): argument 1 has unexpected type 'float'
- OS: Windows 10
- PyQt version: 5
Same thing works a treat on mac os.
Same issue here since I installed labelImg last week. Windows 10.
@zaitsman I think you can either downgrade python version(< 3.10) or change some values' type manually.
For me, I reinstalled python 3.9 and it worked well.
change float to int
You can change the type from float to int and it works but it omits other errors.
( I think the problem is that drawLine
method takes int
type, but the x
function returns float
type as well as setValue
method ? )
switching back to python 3.9 worked for me. thanks @sammiee5311
Hi guys, I have the same problem! But I don't know where is the 'float' to change into an 'int' in the file about @sammiee5311 talked about. (line 530, 531 etc...)
And if someone would explain to me how to downgrade the python version 3.10 to 3.9 as @pradoz said above with cmd.
This is the canvas.py file
Hi guys, I have the same problem! But I don't know where is the 'float' to change into an 'int' in the file about @sammiee5311 talked about. (line 530, 531 etc...)
And if someone would explain to me how to downgrade the python version 3.10 to 3.9 as @pradoz said above with cmd.
This is the canvas.py file
@YanisSadou, You can replace
from p.drawLine(self.prev_point.x(), 0, self.prev_point.x(), self.pixmap.height())
to p.drawLine(int(self.prev_point.x()), 0, int(self.prev_point.x()), int(self.pixmap.height()))
due to values which are float.
However, It does not fix everything so there will be other problems while working with it.
So I recommend you to switch the python version.
First, install any python version lower than 3.10.
Then, If you use windows os, you can change windows PATH
system variables to make reordering python versions.
or you can use virtualenv
<your pip version> install virtualenv
virtualenv --python=<python version> venv
- example
pip3 install virtualenv
virtualenv --python=3.9 venv (or python3 -m virtualenv --python=3.9 venv)
and then install dependencies what you want in the python virtual environment.
@sammiee5311 I just replace some lines in the canvas.py thanks to your advice, change all 'float' to 'int':
- canvas.py#L526
- canvas.py#L530
- canvas.py#L531
- labelImg.py#L965
It seems to work well. You are a goat!
@YanisSadou No worries !
Hi
Seems windows qt has a problem. I will make changes to fix it according to @YanisSadou changes
@tzutalin I think you need to change more than 4 lines
that @YanisSadou replaced.
I don't have a laptop right now. There are another lines need to be fixed in order not to get errors while using it.
Because lots of methods
returns float
instead int
.
@sammiee5311 ,
could you help submit a PR for this bug since I cannot reproduce this on my mac.
Basically, I guess it should have converted to int before calling QT methods like drawLine
. We probably don't need to convert all floats to int. We can keep them. Instead, changing the float to int before calling QT's methods
Thanks in advance!
@tzutalin, Sure !
I will submit a PR after my work done.
I have one question that
Instead, changing the float to int before calling QT's methods
you meant, change like p.drawLine(self.prev_point.x(), ...)
to p.drawLine(int(self.prev_point.x()), ...)
?
Thanks. ya~ I was thinking about this which is the same as you post above
@tzutalin No worries ! Okay, good :)
can you give me the result of changing the int? i dont know how to change it i mean the source code after it
created a new venv using python 3.8 and then pip3 install labelImg then simply type labelImg in the terminal
Also have this issue- when can we expect this to be upgraded to work with Python 3.10?
I'm hitting the same thing after upgrading to Ubuntu 22.04 LTS Python 3.10.6 pip 22.0.2 PyQt5 5.15.6
Hello i to have the same problem, But i don't know where to fix it & how too
Hello i to have the same problem, But i don't know where to fix it & how too
Try downgrading python to version 3.9. From what I saw, it solved almost everyone's problems in my contacts.
Are there any updates on when this will be upgraded to python 3.10? I have many pipelines that have been using 3.10 for a while, but I have to separate this part out to use python 3.9, which is a lot of extra work.
I don't have any idea But it's updated in python3.11
On Fri, 20 Jan, 2023, 7:57 pm richeym-umich, @.***> wrote:
Are there any updates on when this will be upgraded to python 3.10? I have many pipelines that have been using 3.10 for a while, but I have to separate this part out to use python 3.9, which is a lot of extra work.
— Reply to this email directly, view it on GitHub https://github.com/heartexlabs/labelImg/issues/811#issuecomment-1398468302, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY6SOUW35W3IPHRHPCYPAYLWTKOFPANCNFSM5IIPE7CA . You are receiving this because you commented.Message ID: @.***>
I use anaconda to create a virtual environment like python 3.9 or python3.7 But the error still exists Do I need to install labelimg in the virtual environment?
argument 1 has unexpected type 'float', that means it should be 'int' type. p.drawLine(int(self.prev_point.x()), 0, int(self.prev_point.x()), int(self.pixmap.height()))
I made a post talking about how to solve this problem step-by-step, maybe it will help you. https://stackoverflow.com/questions/76937982/labelimg-closes-when-attempting-to-label-error-in-canvas-py-file/77891276#77891276