Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import error when importing PYSIDE6 while using QtPy <= 1.x #227

Closed
duylp opened this issue Feb 28, 2023 · 5 comments · Fixed by #228
Closed

Import error when importing PYSIDE6 while using QtPy <= 1.x #227

duylp opened this issue Feb 28, 2023 · 5 comments · Fixed by #228
Assignees
Labels
Milestone

Comments

@duylp
Copy link

duylp commented Feb 28, 2023

A recent change made qtawesome depend on PYSIDE6, which is not necessary in my opinion.

File ~/python-venv/lib/python3.8/site-packages/qtawesome/iconic_font.py:25
     22 import warnings
     24 # Third party imports
---> 25 from qtpy import PYSIDE2, PYSIDE6
     26 from qtpy.QtCore import (QObject, QPoint, QRect, Qt,
     27                          QSizeF, QRectF, QPointF, QThread)
     28 from qtpy.QtGui import (QColor, QFont, QFontDatabase, QIcon, QIconEngine,
     29                         QPainter, QPixmap, QTransform, QPalette, QRawFont,
     30                         QImage)

ImportError: cannot import name 'PYSIDE6' from 'qtpy'

A simple try/catch would fix this.

@dalthviz
Copy link
Member

Hi @duylp thank you for the feedback! Could you update to the latest qtpy and check again? I think we are missing bumping the constraint for qtpy to be at least >=2.0.0 at https://github.com/spyder-ide/qtawesome/blob/master/setup.py#L35

@dalthviz dalthviz added this to the v1.3.0 milestone Feb 28, 2023
@duylp
Copy link
Author

duylp commented Mar 1, 2023

Hi @dalthviz, thanks for solution, that should work. Reading from the changelog, I don't see any features aside from this depend on PYSIDE6. Would it be better to check if PYSIDE6 exists rather than pinning qtpy>=2.0.0?

In our usage, qtpy is pinned to be 1.x.x so we're currently pinning qtawesome.

@dalthviz dalthviz modified the milestones: v1.3.0, v1.2.3 Mar 1, 2023
@dalthviz
Copy link
Member

dalthviz commented Mar 1, 2023

Thanks for the info @duylp ! I see, so maybe you are still using Qt4? Checking maybe we could change the validation using qtpy.PYSIDE2 or qtpy.PYSIDE6 at

if PYSIDE2 or PYSIDE6:

to use qtpy.PYSIDE_VERSION so:

    if PYSIDE_VERSION:

What do you think @ccordoba12 ? In that way we should not need to constrain qtpy or add try-catch logic, right?

Also @duylp could you check if the change I'm suggesting works in your setup with qtpy <=1.x ? Thank you!

@dalthviz dalthviz self-assigned this Mar 1, 2023
@dalthviz dalthviz changed the title Import error when importing PYSIDE6 Import error when importing PYSIDE6 while using QtPy <= 1.x Mar 1, 2023
@ccordoba12
Copy link
Member

What do you think @ccordoba12 ? In that way we should not need to constrain qtpy or add try-catch logic, right?

Yeah, sounds good to me.

@duylp
Copy link
Author

duylp commented Mar 2, 2023

Thanks, I've tested it and your solution works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants