Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

RuntimeError: the PyQt4.QtCore and PyQt5.QtCore modules both wrap the QObject class #268

Closed
yishen-zhao opened this issue Apr 1, 2018 · 9 comments

Comments

@yishen-zhao
Copy link

File "/home/yishen/labelImg-master/resources.py", line 9, in
from PyQt4 import QtCore
RuntimeError: the PyQt4.QtCore and PyQt5.QtCore modules both wrap the QObject class

I don't install pyqt5

@rcgatto
Copy link

rcgatto commented Apr 5, 2018

Hi,
I have PyQt5. I suggest install PyQt5 and change any reference of PyQt4 to PyQt5 in resources.py and in ./libs/ustr.py.
You will have an error like "ImportError: cannot import name QString" in ustr.py. Just change the line
if type(x) == QString:
to
if type(x) == type('string'):

@vdalv
Copy link
Contributor

vdalv commented May 26, 2018

Closing this because there's already an open issue for this problem: #212

And it appears you've already found a solution... #212 (comment)

@vdalv vdalv closed this as completed May 26, 2018
@rcgatto
Copy link

rcgatto commented May 27, 2018 via email

@osxn
Copy link

osxn commented Jul 1, 2018

meet the same problem.

@osxn
Copy link

osxn commented Jul 1, 2018

when I uninstall pyqt4 and use pyqt5 instead,

Traceback (most recent call last):
File "labelImg.py", line 1456, in
sys.exit(main())
File "labelImg.py", line 1452, in main
app, _win = get_main_app(sys.argv)
File "labelImg.py", line 1445, in get_main_app
argv[3] if len(argv) >= 4 else None)
File "labelImg.py", line 98, in init
self.settings.load()
File "/home/enjoy-life/labelImg/libs/settings.py", line 33, in load
self.data = pickle.load(f)
ImportError: No module named 'PyQt4'

@vdalv
Copy link
Contributor

vdalv commented Jul 1, 2018

@osxn Run this command: pyrcc5 -o resources.py resources.qrc

@rkachach
Copy link

I faced the same issue (I'm using pyqt5). Basically it seems that in qt5 there's no class called string. I used the following workaround in libs/ustr.py and it worked fine:

try:
    from PyQt4.QtCore import QString  
except ImportError:
    # we are using Python3 so QString is not defined
    QString = str

This way, when using qt5 you switch to python string instead of QString.

rjdbcm referenced this issue in rjdbcm/BEAGLES Apr 25, 2019
Add section for training on our own dataset resolves #203
@bessszilard
Copy link

bessszilard commented Jul 11, 2019

Try to install qt5, run make and finally start application with python3:

$ sudo apt-get install pyqt5-dev pyqt5-dev-tools
$ make qt5py3
$ python3 labelImg.py

@Lanme
Copy link

Lanme commented Nov 6, 2019

I use the code from rkachach ,but error still unsolved.Then I realize maybe it's not an improrerror,so after remove the importerror ,it works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants