# Installing MNE-Python¶

## Installing Python¶

MNE-Python runs within Python, and depends on several other Python packages. Starting with version 0.18, MNE-Python only supports Python version 3.5 or higher. We strongly recommend the Anaconda distribution of Python, which comes with more than 250 scientific packages pre-bundled, and includes the conda command line tool for installing new packages and managing different package sets (“environments”) for different projects.

To get started, follow the installation instructions for Anaconda.

Warning

If you have the PYTHONPATH or PYTHONHOME environment variables set, you may run into difficulty using Anaconda. See the Anaconda troubleshooting guide for more information. Note that it is easy to switch between conda-managed Python installations and the system Python installation using the conda activate and conda deactivate commands, so you may find that after adopting Anaconda it is possible (indeed, preferable) to leave PYTHONPATH and PYTHONHOME permanently unset.

When you are done, if you type the following commands in a bash terminal, you should see outputs similar to the following (assuming you installed conda to /home/user/anaconda3):

$conda --version && python --version conda 4.6.2 Python 3.6.7 :: Anaconda, Inc.$ which python
/home/user/anaconda3/bin/python
$which pip /home/user/anaconda3/bin/pip  #### If you get an error or these look incorrect... If you are on a Windows command prompt: Most of our instructions start with $, which indicates that the commands are designed to be run from a Bash command prompt.

Windows command prompts do not expose the same command-line tools as Bash shells, so things like which will not work, and you need to use alternatives, such as:

> where mne
C:\Users\mneuser\Anaconda3\Scripts\mne


If you see something like:

conda: command not found


It means that your PATH variable (what the system uses to find programs) is not set properly. In a correct installation, doing:

$echo$PATH
...:/home/user/anaconda3/bin:...


Will show the Anaconda binary path (above) somewhere in the output (probably at or near the beginning), but the command not found error suggests that it is missing.

On Linux or OSX, the installer should have put something like the following in your ~/.bashrc or ~/.bash_profile (or somewhere else if you are using a non-bash terminal):

. ~/anaconda3/etc/profile.d/conda.sh


If this is missing, it is possible that you are not on the same shell that was used during the installation. You can verify which shell you are on by using the command:

$echo$SHELL


If you do not find this line in the configuration file for the shell you are using (bash, tcsh, etc.), add the line to that shell’s rc or profile file to fix the problem.

If you see an error like:

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.


It means that you have used an old method to set up Anaconda. This means that you have something like:

$conda env update --file environment.yml  #### macOS Use the base environment file and then update PyQt using pip, e.g.: $ curl --remote-name https://raw.githubusercontent.com/mne-tools/mne-python/master/environment.yml
$conda env update --file environment.yml$ pip install "PyQt5>=5.10,<5.14"


#### Windows

• Open an Anaconda command prompt

• cd to the directory where you downloaded the file

• Run conda env update --file environment.yml

If you prefer an isolated Anaconda environment, instead of usingconda env update to modify your “base” environment, you can create a new dedicated environment (here called “mne”) with conda env create --name mne --file environment.yml.

#### If you are installing on a headless server...

Installing mayavi requires a running X server. If you are installing MNE-Python into a computer with no display connected to it, you can try removing mayavi from the environment.yml file before running conda env create --file environment.yml, activating the new environment, and then installing mayavi using xvfb (e.g., xvfb-run pip install mayavi). Be sure to read Mayavi’s instructions on off-screen rendering and rendering with a virtual framebuffer.

Note: if xvfb is not already installed on your server, you will need administrator privileges to install it.

## Testing MNE-Python installation¶

To make sure MNE-Python installed itself and its dependencies correctly, type the following command in a terminal:

\$ mne sys_info


This should display some system information along with the versions of MNE-Python and its dependencies. Typical output looks like this:

Platform:      Linux-4.18.0-13-generic-x86_64-with-debian-buster-sid
Python:        3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34)  [GCC 7.3.0]
Executable:    /home/travis/miniconda/bin/python
CPU:           x86_64: 48 cores
Memory:        62.7 GB

mne:           0.17.0
numpy:         1.15.4 {blas=mkl_rt, lapack=mkl_rt}
scipy:         1.2.0
matplotlib:    3.0.2 {backend=Qt5Agg}

sklearn:       0.20.2
numba:         0.45.0
nibabel:       2.3.3
pandas:        0.24.0
dipy:          0.15.0
mayavi:        4.7.1 {qt_api=pyqt5, PyQt5=5.10.1}
pyvista:       0.21.3
vtk:           8.2.0


#### If you get an error...

If you see an error like:

Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'mne'


This suggests that your environment containing mne is not active. If you installed to the mne instead of base environment, try doing conda activate mne and try again. If this works, you might want to add conda activate mne to the end of your ~/.bashrc or ~/.bash_profile files so that it gets executed automatically.

If something else went wrong during installation and you can’t figure it out, check out the Advanced setup of MNE-Python page to see if your problem is discussed there. If not, the MNE mailing list and MNE gitter channel are good resources for troubleshooting installation problems.