RuntimeError: Could not load any valid 3D backend: pyvista, mayavi, notebook (error only for .py not for IPython)

Hi everyone,
I have got this error while using plot_sensors_connectivity. I only have this error running in the terminal (.py), not in IPython though.

  • MNE-Python version: 0.23.0
  • operating system: windows 10

I saw the same issue here. But I indeed have pyvista and mayavi in my envinronment. See the outputs of mne.sys_info() below:

Platform:      Windows-10-10.0.19041-SP0
Python:        3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]
Executable:    C:\Users\luwan\.conda\envs\mne_new\python.exe
CPU:           Intel64 Family 6 Model 142 Stepping 10, GenuineIntel: 8 cores
Memory:        7.9 GB

mne:           0.23.0
numpy:         1.19.2 {blas=D:\\a\\1\\s\\numpy\\build\\openblas_info, lapack=D:\\a\\1\\s\\numpy\\build\\openblas_lapack_info}
scipy:         1.6.0
matplotlib:    3.3.2 {backend=Qt5Agg}

sklearn:       0.23.2
numba:         0.51.2
nibabel:       3.2.1
nilearn:       0.7.0
dipy:          Not found
cupy:          Not found
pandas:        1.2.1
mayavi:        4.7.4.dev0
pyvista:       0.31.3 {pyvistaqt=0.5.0, OpenGL 4.5.0 - Build 27.20.100.8854 via Intel(R) UHD Graphics 620}
vtk:           9.0.1
PyQt5:         5.9.2

Do I have to do some special setting for running in the terminal? Thanks a lot for the help!

is that the output of mne.sys_info() when run in iPython, or when run in regular Python in the terminal? My best guess would be that this is a problem with conda (or venv?), where typing ipython loads ipython (and python) from one environment, while typing python loads python from a different environment. You can check the third line (“executable”) to check this.