Crash on PySide6 due to version checking
eslickj opened this issue · 1 comments
When I try to run qtconsole on macOS with PySide6, I get this error:
Traceback (most recent call last):
File "/Users/john/miniconda3/envs/idaes/bin/jupyter-qtconsole", line 8, in <module>
sys.exit(main())
File "/Users/john/miniconda3/envs/idaes/lib/python3.10/site-packages/qtconsole/qtconsoleapp.py", line 467, in main
JupyterQtConsoleApp.launch_instance()
File "/Users/john/miniconda3/envs/idaes/lib/python3.10/site-packages/jupyter_core/application.py", line 277, in launch_instance
return super().launch_instance(argv=argv, **kwargs)
File "/Users/john/miniconda3/envs/idaes/lib/python3.10/site-packages/traitlets/config/application.py", line 1040, in launch_instance
app.initialize(argv)
File "/Users/john/miniconda3/envs/idaes/lib/python3.10/site-packages/traitlets/config/application.py", line 113, in inner
return method(app, *args, **kwargs)
File "/Users/john/miniconda3/envs/idaes/lib/python3.10/site-packages/qtconsole/qtconsoleapp.py", line 419, in initialize
v_5_15_2 = QtCore.QVersionNumber.fromString('5.15.2')[0]
TypeError: 'PySide6.QtCore.QVersionNumber' object is not subscriptable
The issue comes from these lines, I assume the QVersionNumber
object is different than expected in PySide6.
# Fixes launching issues with Big Sur
# https://bugreports.qt.io/browse/QTBUG-87014, fixed in qt 5.15.2
#if sys.platform == 'darwin':
# v_5_15_2 = QtCore.QVersionNumber.fromString('5.15.2')[0]
# v_current = QtCore.QVersionNumber.fromString(QT_VERSION)[0]
# if v_current < v_5_15_2:
# os.environ['QT_MAC_WANTS_LAYER'] = '1'
I can reproduce this.
In PyQt6 (6.4.2):
QVersionNumber.fromString('5.15.2')
returns a tuple
:
(<PyQt6.QtCore.QVersionNumber at 0x10313bf40>, 6)
But in Pyside6 (6.4.2):
QVersionNumber.fromString('5.15.2')
returns a PySide6.QtCore.QVersionNumber
and as a result it is not subscriptable.
So either there needs to be a check for pyside6 or perhaps this could be solved by using packaging.version
instead to check the version numbers?
Edit: thinking more, the actual fix only applies to Qt5, so just adding a check for qtpy.QT6 should suffice. Will make PR.