MNE not loading in Spyder

  • MNE version: several, from 1.1.0 to 1.3.1
  • operating system: Windows Server 2022 Standard 21H2, 64-bit
  • Python version: 3.10.10 Anaconda Distribution

We just reinstalled python (v3.10.10 with Anaconda; not using mamba) and then installed MNE via conda install as suggested in the online documentation, and then also spyder-kernels=2.4.

With MNE 1.3.1, we found that after we installed numba, MNE couldn’t be imported anymore in spyder - the console just freezes. Then we tried installing MNE 1.3.0, 1.2.0, and 1.1.0 and found that the same thing happens in Spyder even without installing numba. However, in python console, it is possible to import MNE.

1 Like

I had the same problem before, and it still exists on macos 10.14 and ubuntu 20.04 & 22.04.

The solution for ubuntu 20.04 is to try the mne standalone package installer, which includes spyder and works. But this solution does not work for macos 10.14, you can try if it works for windows.

Thanks for the suggestion. I’ve had had bad experiences with the standalone installer in the past, but maybe I’ll give it a try if I can’t get it to work otherwise.

I’m sorry to hear that! I know there are still numerous rough edges, but we’re trying our best to constantly improve things. If you find a few minutes, would you care to explain what your main pain points were?

cc @larsoner

Thanks,
Richard

Hi Richard, I believe we had a thread about the installer file over a year ago.
But I assume you’ve since updated it, so I’ll let you know how it goes with the new one, should we go with that option.

However, it would be great if the problem I described above with MNE not loading, after installation through conda install could be fixed.

Thanks,
Felix

1 Like

So import mne freezes the console?

If that’s the case, try importing just numpy, scipy.linalg, matplotlib.pyplot, and numba. It’s possible that one of our dependencies is causing a problem (especially since you mention numba).

Another approach would be to start another env and install mne-base instead of mne. This should have way fewer dependencies. If importing works in that env, you can start installing optional deps one by one to find the culprit.

If it ends up being numba you can live without it, it just means some operations (mostly having to do with forward and source space) will be slower.

2 Likes

I figured out a solution now.
The environment folders in \Anaconda\envs\ needed to be shared (via right-click, Properties-> Sharing). When that is done, MNE loads perfectly well in Spyder.

MNE-base does not have this problem, so it is apparently one of MNE’s dependencies that wants to operate in a shared folder.
Might be an issue specific to Windows, or to Windows Server…

2 Likes

Awesome work @fesieben !

Yes it’s probably Numba because they create .so files on the fly in the same directory structure. @richard do you know if we can modify the permissions in the system-level Windows installs?

No, I have no idea. This is probably possible through the NSIS script that is used under the hood, but I’d expect it to require modifications to constructor to expose this functionality.

Or we could use a post-install script like we do on macOS, where we also fiddle with the permissions / ownership post-hoc:

We already have a post-install script for Windows in place, we’d “just” need to add the respective commands