How to recreate valid environment for older MNE version?

  • MNE version: 1.2.3
  • operating system: Linux Compute Server (SUSE 15.5)

I’m trying to debug/refactor some code which I have written a while ago. back then I used MNE v1.2.3.
Unfortunately, in the meantime, I worked on other parts in the same project and updated a few other packages in the same environment. Now that I went back to one of my MNE-based decoding classes, some of my methods, which used to run smoothly, throw errors. I figured out that the problem seems to be that I updated scikit-learn to a newer version which is not compatible with the older MNE version ( #11846 seems to have introduced the relevant change).
So, I rolled back scikit-learn to an older version. This seemed to fix my issue at first glance—just to see that my code now fails a bit further downstream. From a quick inspection, it looks like it’s now numba which gets into my way (which also seems to have been updated; this must have happened as a dependency, I’m pretty sure that I did not touch numba directly myself).

tl;dr this seems to be an almost infinite regress. (Conda is currently trying for almost an hour already to solve my environment with an older version of numba.) How can I go about a situation like this? I tried building a new conda environment dirctly using MNE v1.2.3 but this would also install the latest versions of the dependencies (e.g., scikit-learn) which will make my code fail.
How can I reconfigure an enviroment with package versions that work together?
Thanks for any support & sorry if this is a trivial or basic Python SE, not MNE-specific, question.

Hello,

Conda is currently trying for almost an hour already to solve my environment with an older version of numba

Depending on your conda version, one simple thing would be to try and use a solver that’s faster than conda’s default, e.g. libmamba by adding --solver=libmamba when using conda install.

If you’re using conda >= 23.10, libmamba is already the default solver, but if you’re using an older version (can check by running conda -V in your terminal) this might speed up solving considerably.


Otherwise, if you have an idea of the date when you set up your environment originally (or maybe just when MNE v1.2.3 was released?), you could check for what the versions where for each dependency at this time and create an environment.yml with these specific versions.

This stackoverflow answer has a programmatic solution that may speed this up rather than sifting through them all manually.


Hope this helps!

2 Likes

Thanks, @tsbinns ! That’s a great (and fast :pray: ) response! I wasn’t aware that it’s this easy now to use libmamba. I got it to work now by updating MNE as well. But, yea, this might have broken other parts of the pipeline. :dotted_line_face:

Manually recreating an environment, specifying versions of dependencies of dependencies seems almost impossible to me. If I need to do it, I’ll check out the tool you shared.
Thanks again!

2 Likes

In the (near) future, we really hope to use uv for exactly this purpose. Once it’s ready, we’ll update our documentation accordingly, but feel free to give it a try!

5 Likes