Installation

There are various ways to install Brian, and we recommend that you chose the installation method that they are most familiar with and use for other Python packages. If you do not yet have Python installed on your system (in particular on Windows machines), you can install Python and all of Brian’s dependencies via the Anaconda distribution. You can then install Brian with the conda package manager as detailed below.

Note

You need to have access to Python >=3.7 (see Brian’s support policy). In particular, Brian no longer supports Python 2 (the last version to support Python 2 was Brian 2.3). All provided Python packages also require a 64 bit system, but every desktop or laptop machine built in the last 10 years (and even most older machines) is 64 bit compatible.

If you are relying on Python packages for several, independent projects, we recommend that you make use of separate environments for each project. In this way, you can safely update and install packages for one of your projects without affecting the others. Both, conda and pip support installation in environments – for more explanations see the respective instructions below.

Standard install

We recommend installing Brian into a separate environment, see conda’s documentation for more details. Brian 2 is not part of the main Anaconda distribution, but built using the community-maintained conda-forge project. You will therefore have to to install it from the conda-forge channel. To do so, use:

conda install -c conda-forge brian2

You can also permanently add the channel to your list of channels:

conda config --add channels conda-forge

This has only to be done once. After that, you can install and update the brian2 packages as any other Anaconda package:

conda install brian2

Updating an existing installation

How to update Brian to a new version depends on the installation method you used previously. Typically, you can run the same command that you used for installation (sometimes with an additional option to enforce an upgrade, if available):

Depending on whether you added the conda-forge channel to the list of channels or not (see above), you either have to include it in the update command again or can leave it away. I.e. use:

conda update -c conda-forge brian2

if you did not add the channel, or:

conda update brian2

if you did.

Requirements for C++ code generation

C++ code generation is highly recommended since it can drastically increase the speed of simulations (see Computational methods and efficiency for details). To use it, you need a C++ compiler and Cython (automatically installed as a dependency of Brian).

On Linux and Mac OS X, the conda package will automatically install a C++ compiler. But even if you install Brian in a different way, you will most likely already have a working C++ compiler installed on your system (try calling g++ --version in a terminal). If not, use your distribution’s package manager to install a g++ package.

Try running the test suite (see Installing other useful packages below) after the installation to make sure everything is working as expected.

Development install

When you encounter a problem in Brian, we will sometimes ask you to install Brian’s latest development version, which includes changes that were included after its last release.

We regularly upload the latest development version of Brian to PyPI’s test server. You can install it via:

python -m pip install --upgrade --pre -i https://test.pypi.org/simple/ Brian2

Note that this requires that you already have all of Brian’s dependencies installed.

If you have git installed, you can also install directly from github:

python -m pip install git+https://github.com/brian-team/brian2.git

Finally, in particular if you want to either contribute to Brian’s development or regularly test its latest development version, you can directly clone the git repository at github (https://github.com/brian-team/brian2) and then run pip install -e ., to install Brian in “development mode”. With this installation, updating the git repository is in general enough to keep up with changes in the code, i.e. it is not necessary to install it again.

Installing other useful packages

There are various packages that are useful but not necessary for working with Brian. These include: matplotlib (for plotting), pytest (for running the test suite), ipython and jupyter-notebook (for an interactive console).

conda install matplotlib pytest ipython notebook

You should also have a look at the brian2tools package, which contains several useful functions to visualize Brian 2 simulations and recordings.

As of now, brian2tools is not yet included in the conda-forge channel, you therefore have to install it from our own brian-team channel:

conda install -c brian-team brian2tools

Testing Brian

If you have the pytest testing utility installed, you can run Brian’s test suite:

import brian2
brian2.test()

It should end with “OK”, showing a number of skipped tests but no errors or failures. For more control about the tests that are run see the developer documentation on testing.