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

Not compatible with PySide 6.7 #578

Open
hoechenberger opened this issue May 27, 2024 · 6 comments
Open

Not compatible with PySide 6.7 #578

hoechenberger opened this issue May 27, 2024 · 6 comments

Comments

@hoechenberger
Copy link
Contributor

Hello, it seems pyvistaqt is not compatible with PySide 6.7, even though there is no upper bound for this dependency.

      1 # %%
      2 import mne
----> 4 mne.viz.set_3d_backend('pyvista')
      6 sample_dir = mne.datasets.sample.data_path()
      7 stc_fname = sample_dir / 'MEG' / 'sample' / 'sample_audvis-meg'  # omit suffix

File <decorator-gen-90>:12, in set_3d_backend(backend_name, verbose)

File /workspaces/mne-python/mne/viz/backends/renderer.py:143, in set_3d_backend(backend_name, verbose)
    141 backend_name = _check_3d_backend_name(backend_name)
    142 if MNE_3D_BACKEND != backend_name:
--> 143     _reload_backend(backend_name)
    144     MNE_3D_BACKEND = backend_name
    145 return old_backend_name

File /workspaces/mne-python/mne/viz/backends/renderer.py:44, in _reload_backend(backend_name)
     42 def _reload_backend(backend_name):
     43     global backend
---> 44     backend = importlib.import_module(
     45         name=_backend_name_map[backend_name], package="mne.viz.backends"
     46     )
     47     logger.info(f"Using {backend_name} 3d backend.")

File /opt/conda/lib/python3.12/importlib/__init__.py:90, in import_module(name, package)
     88             break
     89         level += 1
---> 90 return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1387, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1360, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1331, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:935, in _load_unlocked(spec)

File <frozen importlib._bootstrap_external>:995, in exec_module(self, module)

File <frozen importlib._bootstrap>:488, in _call_with_frames_removed(f, *args, **kwds)

File /workspaces/mne-python/mne/viz/backends/_qt.py:23
     21 from matplotlib.backends.backend_qtagg import FigureCanvas
     22 from matplotlib.figure import Figure
---> 23 from pyvistaqt.plotting import FileDialog, MainWindow
     24 from qtpy.QtCore import (
     25     QEvent,
     26     QLibraryInfo,
   (...)
     32     Signal,
     33 )
     34 from qtpy.QtGui import QCursor, QIcon, QKeyEvent

File /opt/conda/lib/python3.12/site-packages/pyvistaqt/__init__.py:40
     37         """Handle Qt binding error for QtInteractor."""
     39 else:
---> 40     from .plotting import BackgroundPlotter, MainWindow, MultiPlotter, QtInteractor
     43 __all__ = [
     44     "__version__",
     45     "BackgroundPlotter",
   (...)
     48     "QtInteractor",
     49 ]

File /opt/conda/lib/python3.12/site-packages/pyvistaqt/plotting.py:154
    150     finally:
    151         BasePlotter.__init__ = init
--> 154 class QtInteractor(QVTKRenderWindowInteractor, BasePlotter):
    155     """Extend QVTKRenderWindowInteractor class.
    156 
    157     This adds the methods available to pyvista.Plotter.
   (...)
    184         being automatically ``Modified``.
    185     """
    187     # pylint: disable=too-many-instance-attributes
    188     # pylint: disable=too-many-statements
    189 
    190     # Signals must be class attributes

File /opt/conda/lib/python3.12/site-packages/pyvistaqt/plotting.py:383, in QtInteractor()
    380         other_plotter.renderers[view_index].camera = renderer.camera
    382 # pylint: disable=invalid-name
--> 383 def dragEnterEvent(self, event: QtGui.QDragEnterEvent) -> None:
    384     """Event is called when something is dropped onto the vtk window.
    385 
    386     Only triggers event when event contains file paths that
    387     exist.  User can drop anything in this window and we only want
    388     to allow files.
    389     """
    390     try:

AttributeError: module 'PySide6.QtPrintSupport' has no attribute 'QDragEnterEvent'
(base) mne-user ➜ /workspaces/mne-python (devcontainer ✗) $ conda list |grep pyside
pyside6                   6.7.1                    pypi_0    pypi
pyside6-addons            6.7.1                    pypi_0    pypi
pyside6-essentials        6.7.1                    pypi_0    pypi
@cbrnr
Copy link

cbrnr commented May 27, 2024

Here's how I fixed the drag and drop issue: cbrnr/mnelab@4b65c81

@larsoner
Copy link
Contributor

Is that the same bug? The error is:

--> 383 def dragEnterEvent(self, event: QtGui.QDragEnterEvent) -> None:

which comes from an AttributeError:

AttributeError: module 'PySide6.QtPrintSupport' has no attribute 'QDragEnterEvent'

In other words, I think QtGui.QDragEnterEvent in the code is somehow showing up as PySide6.QtPrintSupport.QDragEnterEvent, i.e., the QtGui is messed up somehow.

This looks like https://bugreports.qt.io/browse/PYSIDE-2674 . It manifested by trying to do stuff like QtGui.<something> and having it look for the attribute on the wrong object as well. They say they fixed it, but this issue thinks that they maybe didn't fully...

@cbrnr
Copy link

cbrnr commented May 28, 2024

That's weird. Maybe mention in that bug report that the problem still occurs in 6.7.1 (because it claims that it has been fixed in that version)?

@cbrnr
Copy link

cbrnr commented May 28, 2024

Re is that the same bug, it could be, it also showed an incorrect class hierarchy for me. But maybe this was just a problem in this particular method, which I could fix (possibly by working around it)... I remember thinking that it was really weird that somehow the inheritance tree was all messed up, but then didn't look into it further because my original issue had been fixed (worked around). So I'd be really interested if this is a larger issue!

@hoechenberger
Copy link
Contributor Author

hoechenberger commented May 28, 2024

@larsoner Just to be absolutely sure, could you kindly try to reproduce this? I was trying to ensure that I wasn't mixing different installations of Qt and respective bindings, but maybe I messed up. Maybe this is an installation mistake on my end, or a conda packaging problem (even though I installed everything except for Python from PyPI, at least to my knowledge)

@larsoner
Copy link
Contributor

I just reproduced it in mne-tools/mne-python#12629 when I tried to remove the existing !=6.7.1. For some I can't get to the traceback on Azure but it's the same as the one here.

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

No branches or pull requests

3 participants