labelImg
labelImg copied to clipboard
AttributeError: type object 'AlignmentFlag' has no attribute 'AlignLeft'
layout.addWidget(bb, alignment=Qt.AlignmentFlag.AlignLeft) AttributeError: type object 'AlignmentFlag' has no attribute 'AlignLeft'
- Mac OS Big Sur
- PyQt 5.9.2
Just wanted to add that this also happens while working on a new Venv on windows. The problem seems to be related to PYQT6 that changed the way alignmentFlag works now (and maybe the conda version of PYQT=5 is actually installing a RC from PYQT6. source: https://www.pythonguis.com/faq/pyqt6-vs-pyside6/ see enums (yes it's a comparison between pyside, but contains a snippet that explains the behavior)
I think @hdxSS is right
Considering using pipenv and follow how we built in CI/CD workflow https://github.com/tzutalin/labelImg/blob/master/.github/workflows/package.yml
Btw for Conda/python. You just have to close and open a new CMD with your env activated and it will be fixed.
I closed and open a new CMD and it still giving the same error to me:
Command Lines:
-
(baseEnv) C:\Users\entok>cd C:\Users\entok\OneDrive - *****\****\codes\LabelImg
-
(baseEnv) C:\Users\entok\OneDrive - *****\****\codes\LabelImg>python labelImg.py
Error:
-
Traceback (most recent call last): File "labelImg.py", line 1722, in <module> sys.exit(main()) File "labelImg.py", line 1718, in main app, _win = get_main_app(sys.argv) File "labelImg.py", line 1711, in get_main_app args.save_dir) File "labelImg.py", line 119, in __init__ self.label_dialog = LabelDialog(parent=self, list_item=self.label_hist) File "C:\Users\entok\OneDrive - *****\****\codes\LabelImg\libs\labelDialog.py", line 37, in __init__ layout.addWidget(bb, alignment=Qt.AlignmentFlag.AlignLeft) AttributeError: type object 'AlignmentFlag' has no attribute 'AlignLeft'
Windows 10 Miniconda, Python 3.7.11, pyqt 5.9.2
How can I solve this problem?
I fixed the issue by changing a row in libs/labelDialog.py
- row:
layout.addWidget(bb, alignment=Qt.AlignmentFlag.AlignLeft
Changed as
layout.addWidget(bb, alignment=Qt.AlignLeft)
It works for me @StoriesCao
https://forum.pythonguis.com/t/attributeerror-type-object-qt-has-no-attribute-alignment/942/2
They showed in pyqt6 Qt.AlignmentFlag.AlignLeft is used but in pyqt5, Qt.AlignLeft was being used.
I fixed the issue by changing a row in
libs/labelDialog.py
- row:
layout.addWidget(bb, alignment=Qt.AlignmentFlag.AlignLeft
Changed as
layout.addWidget(bb, alignment=Qt.AlignLeft)
It works for me @StoriesCao
https://forum.pythonguis.com/t/attributeerror-type-object-qt-has-no-attribute-alignment/942/2
They showed in pyqt6 Qt.AlignmentFlag.AlignLeft is used but in pyqt5, Qt.AlignLeft was being used.
conda/windows - worked for me, big thanks