Could not load any valid 3D backend: pyvista, mayavi, notebook

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

Hello, I don’t know why, but when I try to import mayavi or pyvisa it gives me the following error:

import mayavi
Changing backend to Qt for Mayavi
Traceback (most recent call last):

  File "<ipython-input-51-391e74ae0ec1>", line 1, in <module>
    import mayavi

ModuleNotFoundError: No module named 'mayavi'


import pyvista
Traceback (most recent call last):

  File "<ipython-input-52-3c968869802d>", line 1, in <module>
    import pyvista

ModuleNotFoundError: No module named 'pyvista'

But when I try python -c "import mne;

mne.sys_info()" in the Anaconda Powershell Prompt they are found:
 
Platform:      Windows-10-10.0.19042-SP0
Python:        3.9.7 | packaged by conda-forge | (default, Sep  2 2021, 17:55:20) [MSC v.1916 64 bit (AMD64)]
Executable:    C:\Users\angel\anaconda3\envs\mne\python.exe
CPU:           Intel64 Family 6 Model 165 Stepping 2, GenuineIntel: 12 cores
Memory:        15.9 GB

mne:           0.23.3
numpy:         1.21.2 {blas=NO_ATLAS_INFO, lapack=lapack}
scipy:         1.7.1
matplotlib:    3.4.3 {backend=Qt5Agg}

sklearn:       0.24.2
numba:         Not found
nibabel:       3.2.1
nilearn:       0.6.2
dipy:          1.3.0
cupy:          Not found
pandas:        1.3.2
mayavi:        4.7.2
pyvista:       0.31.3 {pyvistaqt=0.5.0, OpenGL 4.5.0 - Build 27.20.100.8729 via Intel(R) UHD Graphics}
vtk:           9.0.1
PyQt5:         5.12.3

Could anyone help me to find why it is not working? (I am working in the mne enviroment, not in the base enviroment)

Hello @Angel and welcome to the forum!

Could you try to run sys_info() from your Python prompt instead of from the command line?

import mne
mne.sys_info()

and share the output with us?

1 Like

Hello Richard, and thanks for the help provided.

escribe o pega el cĂłdigo aquĂ­
import mne
mne.sys_info()
Platform:      Windows-10-10.0.19041-SP0
Python:        3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)]
Executable:    C:\Users\angel\anaconda3\python.exe
CPU:           Intel64 Family 6 Model 165 Stepping 2, GenuineIntel: 12 cores
Memory:        15.9 GB

mne:           0.23.0
numpy:         1.20.1 {blas=mkl_rt, lapack=mkl_rt}
scipy:         1.6.2
matplotlib:    3.3.4 {backend=Qt5Agg}

sklearn:       0.24.1
numba:         0.53.1
nibabel:       Not found
nilearn:       Not found
dipy:          Not found
cupy:          Not found
pandas:        1.2.4
mayavi:        Not found
pyvista:       Not found
vtk:           Not found

Why are these modules not loaded in the Python prompt? What is the solution to this problem?

Thanks for all the help again and sorry for the inconvinience (I’m a beginner using MNE).

Hello @Angel,

it appears you’re not running Python from your MNE environment. Either open the “mne” Anaconda Prompt (I think this is what it’s called on Windows?), or type

conda activate mne

(where mne is the name of the environment you created)

Then it should work!
Good luck,
Richard

Hello, I am writing my code in spyder, but using my spyder console I cannot manage to access to MNE. How could I access to MNE using the spyder console? I can only access to MNE using the anaconda prompt, but this prompt is not connected to spyder.

Please see the following section of the installation instructions, explaining how to make Spyder work:

https://mne.tools/stable/install/mne_python.html#python-ides

Hello, I have already done those steps, but when I open spyder again using the mne enviroment the following error ocures:

An error ocurred while starting the kernel
Your Python environment or installation doesn't have the spyder‑kernels module or the right version of it installed (>= 1.10.0 and < 1.11.0). Without this module is not possible for Spyder to create a console for you.

You can install it by running in a system terminal:

conda install spyder‑kernels

or

pip install spyder‑kernels```

When I do that:

(base) PS C:\Users\angel> conda install spyder-kernels
Collecting package metadata (current_repodata.json): done
Solving environment: done

All requested packages already installed.```

I close and open spyder again and the same error keeps occurring.

How could I solve this problem?

Thanks again,
Ángel

Spyder is decomposed in 2 modules: spyder and spyder-kernels. The kernel is needed for the IPython console. In the MNE environment, install spyder-kernels and it will work.

Hello, thanks for the help, but when I do that:

(mne) PS C:\Users\angel> conda install spyder-kernels
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: C:\Users\angel\anaconda3\envs\mne

  added / updated specs:
    - spyder-kernels


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    cloudpickle-1.6.0          |             py_0          30 KB
    spyder-kernels-2.0.5       |   py39haa95532_0         100 KB
    ------------------------------------------------------------
                                           Total:         130 KB

The following NEW packages will be INSTALLED:

  cloudpickle        pkgs/main/noarch::cloudpickle-1.6.0-py_0
  spyder-kernels     pkgs/main/win-64::spyder-kernels-2.0.5-py39haa95532_0


Proceed ([y]/n)? y


Downloading and Extracting Packages
spyder-kernels-2.0.5 | 100 KB    | ############################################################ | 100%
cloudpickle-1.6.0    | 30 KB     | ############################################################ | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

I close and open spyder again and the same error as before keeps occurring.

Do you know what might be the problem?
Thanks

Hello, I tried to downgrade the kernels version to the 1.10.2 version and it looks that for now it’s working.

1 Like

yes, that is expected. The error message you pasted above states

Your Python environment or installation doesn’t have the spyder‑kernels module or the right version of it installed (>= 1.10.0 and < 1.11.0)

So downgrading from spyder-kernels 2.0.5 to spyder-kernels 1.10.2 is the right solution.

For future readers: Spyder is usually installed into “base” environment, so if you want to use the “mne” environment in spyder’s built-in console, you need spyder-kernels installed in the “mne” environment, and its version must match one of the versions that your installed version of spyder is expecting. In other words, spyder’s advice to use conda install spyder-kernels or pip install spyder-kernels is incomplete: you usually also need to specify a particular version, like conda install spyder-kernels==1.10.

1 Like