Installing Nilearn

There are different ways to install Nilearn:

  • Install the latest official release (see below). This is the best approach for most users.

  • Building the package from source. This is mainly needed by users who wish to contribute to the project, as this allows to install an editable version of the project.

Setup a virtual environment

We recommend that you install nilearn in a virtual Python environment, either managed with the standard library venv, uv or with conda (see miniconda for instance). Either way, create and activate a new Python environment.

python3 -m venv 'venv'
source venv/bin/activate

Note that uv allows you to choose the python version.

uv venv 'venv' --python 3.14
source venv/bin/activate

Note that conda allows you to choose the python version.

conda create --name nilearn python=3.14 pip
conda activate nilearn
python3 -m venv 'venv'
venv\Scripts\activate

Note that uv allows you to choose the Python version.

uv venv 'venv' --python 3.14
venv\Scripts\activate

Note that conda allows you to choose the Python version.

conda create --name nilearn python=3.14 pip
conda activate nilearn

Installing Nilearn

You can then install Nilearn. Nilearn comes in different flavor. On top of base Nilearn installation, you can add matplotlib as optional dependency for static visualizations, and matplotlib as well as plotly as optional dependencies for both static and interactive visualizations.

Important

To be able to save images with plotly, make sure that Google Chrome is installed! You can install a compatible Chrome version using the kaleido_get_chrome command in command line or kaleido.get_chrome_sync() function in Python:

import kaleido

kaleido.get_chrome_sync()
pip install nilearn
uv pip install nilearn
pip install 'nilearn[plotting]'
uv pip install 'nilearn[plotting]'
pip install 'nilearn[plotting,plotly]'
python -c "import kaleido;  kaleido.get_chrome_sync()"
uv pip install 'nilearn[plotting,plotly]'
uv run 'python -c "import kaleido;  kaleido.get_chrome_sync()"'

Note that Nilearn also optionally supports rich to get prettier log output and download progress bar. Simply install rich to benefit from those.

pip install rich

Check installation

From a terminal window:

python3 -c 'import nilearn; print(nilearn.__version__)'

Or try importing Nilearn in a Python / IPython session.

import nilearn

If no error is raised, you have installed Nilearn correctly.