error when using create_3d_figure

Hello !

when I type in a Python3 console or in Spyder

import mne
fig_roots = mne.viz.create_3d_figure(size=(600, 400), bgcolor=(0, 0, 0))

I get the following error

Using pyvistaqt 3d backend.
2026-07-23 17:09:42.780 ( 0,822s) [ 774AF2F82000]vtkXOpenGLRenderWindow.:1539 ERR| The result is out of range, failed to get the converted tmp.

mne sys_info
Platform Linux-6.8.0-134-generic-x86_64-with-glibc2.35
Python 3.10.12 (main, Jun 22 2026, 18:55:27) [GCC 11.4.0]
Executable /home/melot/venvironments/fosfornew/bin/python
CPU AMD Ryzen 5 PRO 4650GE with Radeon Graphics (12 cores)
Memory 7.1 GiB

Core
├☒ mne 1.10.0 (outdated, release 1.12.1 is available!)
:check_box_with_check: numpy 2.2.6 (OpenBLAS 0.3.29 with 12 threads)
:check_box_with_check: scipy 1.15.3
:check_box_with_check: matplotlib 3.10.9 (backend=qtagg)

Numerical (optional)
:check_box_with_check: sklearn 1.7.2
:check_box_with_check: numba 0.66.0
:check_box_with_check: nibabel 5.4.2
:check_box_with_check: nilearn 0.14.0
:check_box_with_check: dipy 1.11.0
:check_box_with_check: openmeeg 2.5.16
:check_box_with_check: pandas 2.3.3
:check_box_with_check: h5io 0.2.5
:check_box_with_check: h5py 3.16.0
└☐ unavailable cupy

Visualization (optional)
:check_box_with_check: pyvista 0.48.4 (OpenGL 4.6 (Core Profile) Mesa 23.2.1-1ubuntu3.1~22.04.4 via RENOIR (renoir, LLVM 15.0.7, DRM 3.57, 6.8.0-134-generic))
:check_box_with_check: pyvistaqt 0.12.0
:check_box_with_check: vtk 9.6.2
:check_box_with_check: qtpy 2.4.3 (PyQt6=6.4.2)
:check_box_with_check: ipympl 0.10.0
:check_box_with_check: pyqtgraph 0.14.0
:check_box_with_check: mne-qt-browser 0.7.5
:check_box_with_check: ipywidgets 8.1.8
:check_box_with_check: trame_client 3.13.2
:check_box_with_check: trame_server 3.12.5
:check_box_with_check: trame_vtk 2.11.13
:check_box_with_check: trame_vuetify 3.2.2

Ecosystem (optional)
:check_box_with_check: neo 0.14.5
:check_box_with_check: eeglabio 0.1.3
:check_box_with_check: edfio 0.4.14
:check_box_with_check: mffpy 0.11.0
:check_box_with_check: pybv 0.8.1
└☐ unavailable mne-bids, mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline

To update to the latest supported release version to get bugfixes and improvements, visit Updating MNE-Python — MNE 1.12.1 documentation

Do you see how I could fix this issue ?

Thank you very much
with best regards
Clothilde

Are you by any chance using Wayland? 3D graphics are currently not supported on Wayland (because VTK doesn’t support the EGL context provided by QT… it’s technical and I hope they support it one day). What I do instead is set the environment variable QT_QPA_PLATFORM=xcb before running python (or ipython, or jupyter) to force graphics to run in XWayland compatibility mode. Not perfect but it does work.

Thank you very much for your answer. I tried in a terminal

(fosfornew) melot@93A51:~$ export QT_QPA_PLATFORM=xcb
(fosfornew) melot@93A51:~$ spyder&
[1] 9135
(fosfornew) melot@93A51:~$ Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.

and running my code I got the following error in the Ipython Terminal of Spyder.
The figure did not show up with the commande create_3d_figure but when I run

surfer_kwargs = dict(
surface=“white”, # pial
hemi=“both”,
subjects_dir=subjects_dir,
clim=“auto”,
views=“lat”,
initial_time = 0,
time_unit=“s”,
size=(800, 800),
smoothing_steps=5, )

brain_both = stc_Roots.plot(**surfer_kwargs, figure=fig_roots)
brain_both.add_text(0.1, 0.9,‘visualization of roots by level’, “title”, font_size=16)

A figure showed up but this was impossible to access to the data.

Do you think I can fix the issue ?
Thank you by advance !

with best regards !
Clothilde


AttributeError Traceback (most recent call last)
File ~/venvironments/fosfornew/lib/python3.10/site-packages/matplotlib/backends/backend_qt.py:266, in FigureCanvasQT.eventFilter(self, source, event)
265 def eventFilter(self, source, event):
→ 266 if event.type() == QtCore.QEvent.Type.DevicePixelRatioChange:
267 self._update_pixel_ratio()
268 return super().eventFilter(source, event)

File /usr/lib/python3.10/enum.py:437, in EnumMeta.getattr(cls, name)
435 return cls.member_map[name]
436 except KeyError:
→ 437 raise AttributeError(name) from None

AttributeError: DevicePixelRatioChange

I can only get 3d graphics in spyder to work if I start it like this:

QT_QPA_PLATFORM=xcb QT_API=pyqt5 spyder