mne-python is an open-source Python package for exploring, visualizing, and analyzing human neurophysiological data: MEG, EEG, sEEG, ECoG, NIRS, and more. This is an installation guide that includes several helpful tips to avoid headaches.

Get your anaconda version!

We want to install mne-python and we want to do it in a safe place, correct? Anaconda gives us plenty of safe spaces to do this. In fact, Anaconda allows us to comfortably manage (through a command line interface) several python development environments, each with its own packages, dependencies and version of python. Cool isn’t it? Download Anaconda here.

Not sure if your machine is 32-bit or 64-bit? Open a cmd and type :

wmic os get osarchitecture

The otput should be pretty obvious!

Once you have downloaded the executable, open it and follow the instructions to install Anaconda. If everything went smoothly, looking through your programs you should find Anaconda Prompt open it and type:

conda --version

If the result says something like:

"conda not recognized as an internal or external command"

return to step 1, if not, you made it! Here is a brief introduction to Anaconda.

Get mne-python

When someone builds a python package, they use other python packages which in turn use other python packages. This results in a mountain of packages for every package you want to install; or more simply dependencies. Let’s install mne-python dependencies. mne-python is an open source library, that means anyone can collaborate on the code including you, the source code can be found here. In this case, from the offical repo, we take the environment.yml file, a list of the dependencies we need. Open a Windows PowerShell, you can find it by searching for it in the Start menu. Navigate to a folder of your choice using the cd command (how to use command line on windows). When you are in the desired folder type:

wget https://raw.githubusercontent.com/mne-tools/mne-python/main/environment.yml -Outfile environment.yml

This downloads a new file environment.yml in the folder where you are located. Now go back to your Anaconda Prompt, if you closed it, open a new one and navigate to the folder where you downloaded the environment.yml file. Type:

conda env update --file environment.yml

This may take a while. This command creates a new environment called mne that contains mne-python and all its dependencies.

Let’s test it out!

To use the new environment just open a new Anaconda Prompt and type:

C:\>conda activate mne
(mne) C:\>

(mne) means that you are currently inside that environment. each environment as we have previously seen has its own python interpreter, which you can access by typing:

(mne) C:\>python
Python 3.8.6 | packaged by conda-forge | (default, Jan 25 2021, 22:54:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Inside the interpreter import mne and press enter, then type mne.__version__ and press enter. If everything went correctly you should see something like this!

>>> import mne
>>> mne.__version__
'0.22.0'
>>>