Install via pip
or conda
#
Hint
If you’re unfamiliar with Python, we recommend using our MNE-Python installers instead.
MNE-Python requires Python version 3.8 or higher. If you need help installing Python, please refer to our Installing Python guide.
Installing MNE-Python with all dependencies#
If you use Anaconda, we suggest installing 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 the new libmamba
solver instead, which is much faster. To permanently change to this solver,
you can set CONDA_SOLVER=libmamba
in your environment or run
conda config --set solver libmamba
. Below we just use --solver
in each command.
Run in your terminal:
$ conda install --channel=conda-forge --name=base conda-libmamba-solver
$ conda create --solver=libmamba --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 to install FreeSurfer.
Installing MNE-Python with core dependencies#
If you only need MNE-Python’s core functionality, which includes 2D plotting
(but does not support 3D visualization), install via pip
:
$ pip install mne
or via conda
:
$ conda create --override-channels --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
).
This minimal installation requires only a few dependencies. If you need additional functionality later on, you can install individual packages as needed.
Installing MNE-Python with HDF5 support#
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 --override-channels --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
).
If you have already installed MNE-Python with core dependencies (e.g. via pip install mne
),
you can install these two packages to unlock HDF5 support:
$ pip install h5io pymatreader
Installing MNE-Python for other scenarios#
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).
Python IDEs#
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 extension ecosystem. 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 commandspyder
(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 installmne
in a separate environment, as explained in previous sections. Then, instruct Spyder to use themne
environment as its default interpreter by opening Spyder and navigating toTools > 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 themne
environment with the following commands in the terminal, where you replace...
with the exact version ofspyder-kernels
that Spyder tells you it requires.$ conda activate mne $ conda install --override-channels --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
) orpyqt
(conda
) must be installed in themne
environment.PyCharm is an IDE specifically for Python development that provides an all-in-one solution (no extension packages needed). PyCharm comes in a free and open-source Community edition as well as a paid Professional edition.