Download and Install

Summary

  • if you don’t have it, install Python using the instructions below;

  • if you don’t have it, install Pip using the instructions below;

  • if you don’t have them, install NumPy >= 1.6 and Scipy >= 0.9 using the instructions below;

  • install Nipy with something like:

    pip3 install --user nipy
    

Note

These instructions are for Python 3. If you are using Python 2.7, use python2 instead of python3 and pip2 instead of pip3, for the commands below.

Details

Install Python, Pip, Numpy and Scipy

First install Python 3, then install the Python package installer Pip.

Install Python 3 on Linux

We recommend:

  • sudo apt-get install -y python3 python3-tk (Debian, Ubuntu);
  • sudo dnf install -y python3 python3-tkinter (Fedora).

These are the bare minimum installs. You will almost certainly want to install the development tools for Python to allow you to compile other Python packages:

  • sudo apt-get install -y python3-dev (Debian, Ubuntu);
  • sudo dnf install -y python3-devel (Fedora).

Now Install Pip on Linux or macOS.

Install Python 3 on macOS

We recommend you install Python 3.5 or later using Homebrew (http://brew.sh/):

brew install python3

Homebrew is an excellent all-round package manager for macOS that you can use to install many other free / open-source packages.

Now Install Pip on Linux or macOS.

Install Pip on Linux or macOS

Pip can install packages into your main system directories (a system install), or into your own user directories (a user install). We strongly recommend user installs.

To get ready for user installs, put the user local install bin directory on your user’s executable program PATH. First find the location of the user bin directory with:

python3 -c 'import site; print(site.USER_BASE + "/bin")'

This will give you a result like /home/your_username/.local/bin (Linux) or /Users/your_username/Library/Python/3.5/bin (macOS).

Use your favorite text editor to open the ~/.bashrc file (Linux) or .bash_profile (macOSX) in your home directory.

Add these lines to end of the file:

# Put the path to the local bin directory into a variable
py3_local_bin=$(python3 -c 'import site; print(site.USER_BASE + "/bin")')
# Put the directory at the front of the system PATH
export PATH="$py3_local_bin:$PATH"

Save the file, and restart your terminal to load the configuration from your ~/.bashrc (Linux) or ~/.bash_profile (macOS) file. Confirm that you have the user install directory in your PATH, with:

echo $PATH

Now install the Python package installer Pip into your user directories (see: install pip with get-pip.py):

# Download the get-pip.py installer
curl -LO https://bootstrap.pypa.io/get-pip.py
# Execute the installer for Python 3 and a user install
python3 get-pip.py --user

Check you have the right version of the pip3 command with:

which pip3

This should give you something like /home/your_username/.local/bin/pip3 (Linux) or /Users/your_username/Library/Python/3.5/bin (macOS).

Now Install Numpy and Scipy on Linux or macOS.

Install Numpy and Scipy on Linux or macOS

Now you’ve followed the instructions above, install Numpy and Scipy with:

pip3 install --user numpy scipy

Install Python 3, Pip, NumPy and Scipy on Windows

It’s worth saying here that very few scientific Python developers use Windows, so if you’re thinking of making the switch to Linux or macOS, now you have another reason to do that.

That said, if you are installing on Windows, we recommend the Python 3 version of Anaconda. This is a large installer that will install many scientific Python packages, as well as Python itself, and Pip, the package manager.

The machinery for the Anaconda bundle is not completely open-source, and is owned by a company, Continuum Analytics. If you would prefer to avoid using the Anaconda installer:

  1. Download and install the Python 3 installer from the https://python.org website;

  2. Download and install Pip following the instructions at install pip with get-pip.py;

  3. Download and install the Visual C++ redistributable packages for VC++ 2015;

  4. Download the following packages from Christoph Gohlke’s unofficial Windows binaries:

    • numpy (MKL version);
    • scipy (MKL version);

    and install these packages with Pip.

Install Nipy

Now you have Pip:

pip3 install --user nipy

On Windows, macOS, and nearly all Linux versions on Intel, this will install a binary (Wheel) package of NiPy.

Other packages we recommend

Building from latest source code

Dependencies for build

  • A C compiler: Nipy does contain a few C extensions for optimized routines. Therefore, you must have a compiler to build from source. Use XCode for your C compiler on macOS. On Windows, you will need the Microsoft Visual C++ version corresponding to your Python version - see using MSVC with Python. On Linux you should have the packages you need after you install the python3-dev (Debian / Ubuntu) or python3-devel (Fedora) packages using the instructions above;
  • Cython 0.12.1 or later: Cython is a language that is a fusion of Python and C. It allows us to write fast code using Python and C syntax, so that it is easier to read and maintain than C code with the same functionality;
  • Git version control software: follow the instructions on the main git website to install Git on Linux, macOS or Windows.

Procedure

Please look through the development quickstart documentation. There you will find information on building NIPY, the required software packages and our developer guidelines. Then:

# install Cython
pip3 install --user cython
# Clone the project repository
git clone https://github.com/nipy/nipy

to get the latest development version, and:

# Build the latest version in-place
cd nipy
pip3 install --user --editable .

to install the code in the development tree into your Python path.

Installing useful data files

See Optional data packages for some instructions on installing data packages.