labelImg icon indicating copy to clipboard operation
labelImg copied to clipboard

AttributeError: type object 'AlignmentFlag' has no attribute 'AlignLeft'

Open G-Cao opened this issue 2 years ago • 6 comments

layout.addWidget(bb, alignment=Qt.AlignmentFlag.AlignLeft) AttributeError: type object 'AlignmentFlag' has no attribute 'AlignLeft'

  • Mac OS Big Sur
  • PyQt 5.9.2

G-Cao avatar Jun 15 '22 12:06 G-Cao

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)

hdxSS avatar Jun 17 '22 13:06 hdxSS

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

tzutalin avatar Jun 18 '22 04:06 tzutalin

Btw for Conda/python. You just have to close and open a new CMD with your env activated and it will be fixed.

hdxSS avatar Jun 18 '22 07:06 hdxSS

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?

CemEntok avatar Aug 02 '22 13:08 CemEntok

I fixed the issue by changing a row in libs/labelDialog.py

  1. 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.

CemEntok avatar Aug 02 '22 13:08 CemEntok

I fixed the issue by changing a row in libs/labelDialog.py

  1. 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

DreamCookie avatar Sep 03 '22 11:09 DreamCookie