天天看点

解决labelImg.py运行报错ImportError: No module named PyQt4.QtCore

 ubuntu上,原本整体复制了一个labelImg的文件夹,运行labelImg就可以用,但这两天突然报错ImportError: No module named PyQt4.QtCore。

似乎是因为我使用的是pyqt5,但pyqt5没有string这个类,找到解决方法:在labelImg文件夹下编辑 libs/ustr.py这个文件,修改插入如下代码

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

然后,python labelImg.py就可以用了