MNE, Spyder, and CUPY

Hi all, I’m installing MNE for the first time in Anaconda following these instructions: Install via pip or conda — MNE 1.2.2 documentation

I successfully created the MNE environment. I then installed Spyder 5 into a separate environment with these instructions for a Conda-based distribution: Installation Guide — Spyder 5 documentation

I set Spyder to use the mne environment as its default interpreter and had some difficulty with spyder-kernels. Spyder says it “doesn’t have the spyder‑kernels module or the right version of it installed (>= 2.3.0 and < 2.4.0). Without this module is not possible for Spyder to create a console for you.”

So I tried to install spyder-kernels into the mne environment with the following code, ensuring I’m in the mne environment (conda took forever and failed too, so I used mamba):

mamba install --strict-channel-priority --channel=conda-forge spyder-kernels=2.3

I receive the following error: “package spyder-kernels-2.3.0-py310h5588dad_0 requires ipython >=7.31.1,<8.0.0, but none of the providers can be installed”

So I thought, I’ll skip Spyder and use a different IDE or figure out Spyder later. So I moved on to cupy:

mamba install cupy

I get the following error:

"pkgs/r/win-64 No change
pkgs/main/noarch No change
pkgs/r/noarch No change
pkgs/msys2/win-64 No change
pkgs/main/win-64 No change
pkgs/msys2/noarch No change

Pinned packages:

  • python 3.10.*

Encountered problems while solving:

  • package cupy-8.3.0-py39h1c34636_0 requires python >=3.9,<3.10.0a0, but none of the providers can be installed"

I know the standalone installer is an option, but I thought maybe this could help describe someone’s experience trying to configure mne for the first time and the problems encountered.

Here’s the installation test:

(mne) C:\Users\baz8>python -c “import mne; mne.sys_info()”
Platform: Windows-10-10.0.19044-SP0
Python: 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:16:33) [MSC v.1929 64 bit (AMD64)]
Executable: C:\Users\baz8\AppData\Local\Continuum\anaconda3\envs\mne\python.exe
CPU: Intel64 Family 6 Model 158 Stepping 10, GenuineIntel: 12 cores
Memory: 15.9 GB

mne: 1.2.3
numpy: 1.23.5 {unknown linalg bindings}
scipy: 1.9.3
matplotlib: 3.6.2 {backend=QtAgg}

sklearn: 1.1.3
numba: 0.56.4
nibabel: 4.0.2
nilearn: 0.9.2
dipy: 1.5.0
openmeeg: Not found
cupy: Not found
pandas: 1.5.2
pyvista: 0.37.0 {OpenGL 4.5.0 NVIDIA 431.65 via GeForce GTX 1660 Ti/PCIe/SSE2}
pyvistaqt: 0.9.0
ipyvtklink: 0.2.2
vtk: 9.2.2
qtpy: 2.3.0 {PyQt5=5.15.6}
ipympl: Not found
pyqtgraph: 0.13.1
pooch: v1.6.0

mne_bids: Not found
mne_nirs: Not found
mne_features: Not found
mne_qt_browser: 0.4.0
mne_connectivity: Not found
mne_icalabel: Not found

Pip often works for the spyder-kernels install when conda/mamba doesn’t. Not sure about cupy.

This should work - change to your conda env:
pip install spyder-kernels==2.3.0
or pip install spyder-kernels==2.3.*

-Jeff

2 Likes

Thanks, Jeff. Should I be concerned about using pip in a Conda environment? (I’ve read that can create inconsistencies in the environment.)

Sometimes you will need to use pip to install things - just because there are probably >10X the number of python packages on pypy (or pip installable through git) than on conda.

Specifically for spyder-kernels, I have not run into any issues. It only installs a few pieces of extra code.

From my experience the conda environments have a limited lifetime, and I wouldn’t keep trying to update them for too long. Its better/easier to just keep a list of your installed pieces of code and then your install will be two lines of code (conda/mamba installs, then followup pip installs) - (conda export to yml files are another route as well). Save these with your analysis code. This will keep your environment clean and reproducible - this is super helpful when you want to test on one machine and move your analysis to another machine later.

-Jeff

1 Like

Also as a followup - if you really want to stay consistent with conda - you can just install spyder into your conda environment (then you will not need spyder-kernels). This uses extra storage and is probably not a good strategy - but it will work.

conda activate mne
mamba install spyder
1 Like

Thank you for the tips about environment management.

Interesting, even when I do

conda activate mne
mamba install spyder

I get the following:

Encountered problems while solving:

  • package spyder-5.1.5-py310haa95532_1 requires ipython >=7.6.0, but none of the providers can be installed

This is a similar error message to the one I reported above when I tried using mamba to install spyder-kernels: “package spyder-kernels-2.3.0-py310h5588dad_0 requires ipython >=7.31.1,<8.0.0, but none of the providers can be installed”

Can you try the following - just make a new conda environment. It is most likely conflicts with python==3.10, so just install everything with python 3.9.

mamba create -n <MNE_NEW_NAME> --strict-channel-priority --channel=conda-forge spyder mne python=3.9

-Jeff

3 Likes

Jeff,

This worked perfectly. (And it installed much faster than when I first tried this.) Spyder and cupy are both working. Thanks so much for your assistance.

1 Like