pip
or conda
#Hint
If you’re unfamiliar with Python, we recommend using our MNE-Python installers instead.
MNE-Python requires Python version 3.7 or higher. If you need to install Python, please see Installing Python.
We suggest to install MNE-Python into its own conda
environment.
The dependency stack is large and may take a long time (several tens of
minutes) to resolve on some systems via the default conda
solver. We
therefore highly recommend using mamba
instead, a conda
replacement that is much faster.
Run in your terminal:
$ conda install --channel=conda-forge --name=base mamba
$ mamba create --override-channels --channel=conda-forge --name=mne mne
This will create a new conda
environment called mne
(you can adjust
this by passing a different name via --name
) and install all
dependencies into it.
If you need to convert structural MRI scans into models of the scalp, inner/outer skull, and cortical surfaces, you will also need FreeSurfer.
If you only need MNE-Python’s core functionality including 2D plotting (but
without 3D visualization), install via pip
:
$ pip install mne
or via conda
:
$ conda create --strict-channel-priority --channel=conda-forge --name=mne mne-base
This will create a new conda
environment called mne
(you can adjust
this by passing a different name via --name
).
If you plan to use MNE-Python’s functions that require HDF5 I/O (this
includes mne.io.read_raw_eeglab()
, mne.SourceMorph.save()
, and
others), you should run via pip
:
$ pip install mne[hdf5]
or via conda
$ conda create --strict-channel-priority --channel=conda-forge --name=mne mne-base h5io h5py pymatreader
This will create a new conda
environment called mne
(you can adjust
this by passing a different name via --name
).
The Advanced setup page has additional tips and tricks for special situations (servers, notebooks, CUDA, installing the development version, etc). The Contributing guide has additional installation instructions for (future) contributors to MNE-Python (e.g, extra dependencies for running our tests and building our documentation).
Most users find it convenient to write and run their code in an Integrated Development Environment (IDE). Some popular choices for scientific Python development are:
Visual Studio Code (often shortened to “VS Code” or “vscode”) is a development-focused text editor that supports many programming languages in addition to Python, includes an integrated terminal console, and has a rich ecosystem of packages to extend its capabilities. Installing Microsoft’s Python Extension is enough to get most Python users up and running. VS Code is free and open-source.
Spyder is a free and open-source IDE developed by and for scientists who
use Python. It is included by default in the base
environment when you
install Anaconda, and can be started from a terminal with the command
spyder
(or on Windows or macOS, launched from the Anaconda Navigator GUI).
It can also be installed with dedicated installers.
To avoid dependency conflicts with Spyder, you should install mne
in a
separate environment, like explained in the earlier sections. Then, set
Spyder to use the mne
environment as its default interpreter by opening
Spyder and navigating to
Tools > Preferences > Python Interpreter > Use the following interpreter
.
There, paste the output of the following terminal commands
$ conda activate mne
$ python -c "import sys; print(sys.executable)"
It should be something like C:\Users\user\anaconda3\envs\mne\python.exe
(Windows) or /Users/user/opt/anaconda3/envs/mne/bin/python
(macOS).
If the Spyder console can not start because spyder-kernels
is missing,
install the required version in the mne
environment with the following
commands in the terminal, where you replace ...
with the exact version of
spyder-kernels
that Spyder tells you it requires.
$ conda activate mne
$ conda install --strict-channel-priority --channel=conda-forge spyder-kernels=...
Refer to the Spyder documentation
for more information about spyder-kernels
and the version matching.
If the Spyder graphic backend is not set to inline
but to e.g. Qt5
,
PyQt5
(pip
) or pyqt
(conda
) must be installed in the mne
environment.
PyCharm is an IDE specifically for Python development that provides an all-in-one installation (no extension packages needed). PyCharm comes in a free “community” edition and a paid “professional” edition, and is closed-source.