ImportError: cannot import name 'QActionGroup' from 'pivy.qt.QtWidgets'
Opened this issue · 5 comments
As shown below, a test of my pivy build shows that some Qt classes are missing, namely QActionGroup and QAction
>>> from pivy import qt
>>> from pivy.qt import QtWidgets
>>> from pivy import coin, quarter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/pivy/quarter/__init__.py", line 17, in <module>
from . import QuarterWidget
File "/usr/lib/python3/dist-packages/pivy/quarter/QuarterWidget.py", line 127, in <module>
from .ContextMenu import ContextMenu
File "/usr/lib/python3/dist-packages/pivy/quarter/ContextMenu.py", line 20, in <module>
from pivy.qt.QtWidgets import QMenu, QActionGroup, QAction
ImportError: cannot import name 'QActionGroup' from 'pivy.qt.QtWidgets' (/usr/lib/python3/dist-packages/pivy/qt/QtWidgets/__init__.py)
What would be the cause of this?
Okay, I've just confirmed that this problem is from PySide
>>> from PySide6.QtWidgets import QActionGroup
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'QActionGroup' from 'PySide6.QtWidgets' (/home/Olumide/.local/lib/python3.10/site-packages/PySide6/QtWidgets.abi3.so)
Both classes now load.
In desperation I tried lots of things, the last of which was pip install --upgrade --force-reinstall PySide6
so I guess that did the trick.
Now I can run some of the tests but sadly not visual_test.py. I keep getting the error
QWidget: Must construct a QApplication before a QWidget
Aborted (core dumped)
Using pdb, I tracked the problem to the QGLWidget constructor:
$ python3 -m pdb visual_test.py
> /home/Olumide/Downloads/src/pivy/tests/visual_test.py(1)<module>()
-> import sys
(Pdb) b /usr/lib/python3/dist-packages/pivy/quarter/QuarterWidget.py:199
Breakpoint 1 at /usr/lib/python3/dist-packages/pivy/quarter/QuarterWidget.py:199
(Pdb) r
> /usr/lib/python3/dist-packages/pivy/quarter/QuarterWidget.py(199)__init__()
-> QtOpenGL.QGLWidget.__init__(self, *args[:len(params)])
(Pdb) bt
/usr/lib/python3.10/bdb.py(598)run()
-> exec(cmd, globals, locals)
<string>(1)<module>()
/home/Olumide/Downloads/src/pivy/tests/visual_test.py(29)<module>()
-> main()
/home/Olumide/Downloads/src/pivy/tests/visual_test.py(20)main()
-> viewer = quarter.QuarterWidget()
> /usr/lib/python3/dist-packages/pivy/quarter/QuarterWidget.py(199)__init__()
-> QtOpenGL.QGLWidget.__init__(self, *args[:len(params)])
Are the tests up to date? Or is my version of Qt and PySide version 6.6.1 unsupported? I am happy to downgrade but I am not sure to which version.
I've rebuilt soqt, quarter and pivy to use QT5 but the situation is now worse :-(
>>> from pivy.qt import QtWidgets
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/pivy/__init__.py", line 30, in <module>
from .coin import SoDB, SoNodeKit, SoInteraction
File "/usr/lib/python3/dist-packages/pivy/coin.py", line 40397, in <module>
class SoGeo(object):
File "/usr/lib/python3/dist-packages/pivy/coin.py", line 40431, in SoGeo
__swig_destroy__ = _coin.delete_SoGeo
AttributeError: module 'pivy._coin' has no attribute 'delete_SoGeo'
>>> from pivy import coin, quarter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/pivy/__init__.py", line 30, in <module>
from .coin import SoDB, SoNodeKit, SoInteraction
File "/usr/lib/python3/dist-packages/pivy/coin.py", line 40397, in <module>
class SoGeo(object):
File "/usr/lib/python3/dist-packages/pivy/coin.py", line 40431, in SoGeo
__swig_destroy__ = _coin.delete_SoGeo
AttributeError: module 'pivy._coin' has no attribute 'delete_SoGeo'
you are right, there were some changes in qt6/PySide6.
QWorkspace -> QMdiArea
PySide2.QtOpenGL.QGLWidget -> PySide6.QtOpenGLWidgets.QOpenGLWidget
and maybe more
I'm going to rebuild all dependencies with QT6 and try the examples e.g.
https://github.com/coin3d/pivy/blob/master/examples/Mentor/02.1.HelloCone.py
Update
>>> import sys
>>>
>>> from pivy.sogui import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/pivy/__init__.py", line 30, in <module>
from .coin import SoDB, SoNodeKit, SoInteraction
File "/usr/lib/python3/dist-packages/pivy/coin.py", line 40397, in <module>
class SoGeo(object):
File "/usr/lib/python3/dist-packages/pivy/coin.py", line 40431, in SoGeo
__swig_destroy__ = _coin.delete_SoGeo
AttributeError: module 'pivy._coin' has no attribute 'delete_SoGeo'
>>> from pivy.coin import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/pivy/__init__.py", line 30, in <module>
from .coin import SoDB, SoNodeKit, SoInteraction
File "/usr/lib/python3/dist-packages/pivy/coin.py", line 40397, in <module>
class SoGeo(object):
File "/usr/lib/python3/dist-packages/pivy/coin.py", line 40431, in SoGeo
__swig_destroy__ = _coin.delete_SoGeo
AttributeError: module 'pivy._coin' has no attribute 'delete_SoGeo'
Basically, the situation is much worse. I've also tried downgrading to 0.6.8 but that didn't work either. Holding out for help.