Installation#

BrainPy is designed to run cross platforms, including Windows, GNU/Linux, and OSX. It only relies on Python libraries.

Installation with pip#

You can install BrainPy from the pypi. To do so, use:

pip install brainpy

To update the BrainPy version, you can use

pip install -U brainpy

If you want to install the pre-release version (the latest development version) of BrainPy, you can use:

pip install --pre brainpy

Installation from source#

If you decide not to use conda or pip, you can install BrainPy from GitHub, or OpenI.

To do so, use:

pip install git+https://github.com/PKU-NIP-Lab/BrainPy

# or

pip install git+https://git.openi.org.cn/OpenI/BrainPy

Dependency 1: NumPy#

In order to make BrainPy work normally, users should install several dependent Python packages.

The basic function of BrainPy only relies on NumPy, which is very easy to install through pip or conda:

pip install numpy

# or

conda install numpy

Dependency 2: JAX#

BrainPy relies on JAX. JAX is a high-performance JIT compiler which enables users to run Python code on CPU, GPU, and TPU devices. Core functionalities of BrainPy (>=2.0.0) have been migrated to the JAX backend.

Linux & MacOS#

Currently, JAX supports Linux (Ubuntu 16.04 or later) and macOS (10.12 or later) platforms. The provided binary releases of JAX for Linux and macOS systems are available at https://storage.googleapis.com/jax-releases/jax_releases.html .

To install a CPU-only version of JAX, you can run

pip install --upgrade "jax[cpu]"

If you want to install JAX with both CPU and NVidia GPU support, you must first install CUDA and CuDNN, if they have not already been installed. Next, run

pip install --upgrade "jax[cuda]" -f https://storage.googleapis.com/jax-releases/jax_releases.html

Alternatively, you can download the preferred release “.whl” file for jaxlib, and install it via pip:

pip install xxxx.whl

pip install jax

Warning

For m1 macOS users, you should run your python environment on Apple silicon instead of intel silicon since rosetta2 cannot translate jaxlib. One suggestion is uninstall miniconda3 and install miniforge3 for managing your python environment.

Windows#

For Windows users, JAX can be installed by the following methods:

pip install xxxx.whl

pip install jax

Other Dependency#

In order to get full supports of BrainPy, we recommend you install the following packages:

  • Numba: needed in some NumPy-based computations

pip install numba

# or

conda install numba
  • brainpylib: needed in dedicated operators

pip install brainpylib
  • matplotlib: required in some visualization functions, but now it is recommended that users explicitly import matplotlib for visualization

pip install matplotlib

# or

conda install matplotlib
  • NetworkX: needed in the visualization of network training

pip install networkx

# or

conda install networkx