We recommend users to use the Anaconda distribution by Continuum Analytics. Its use will make the installation of Brian 2 and its dependencies simpler, since packages are provided in binary form, meaning that they don’t have to be build from the source code at your machine. Furthermore, our automatic testing on the continuous integration services travis and azure are based on Anaconda, we are therefore confident that it works under this configuration.
However, Brian 2 can also be installed independent of Anaconda, either with
other Python distributions (Enthought Canopy,
Python(x,y) for Windows, …) or simply
based on Python and
pip (see Installation with pip below).
Download the Anaconda distribution for your Operating System. Note, Brian 2 no longer supports Python 2 (the last version to support Python 2 was brian2.3).
After the installation, make sure that your environment is configured to use
the Anaconda distribution. You should have access to the
conda command in
a terminal and running
python (e.g. from your IDE) should show a header like
this, indicating that you are using Anaconda’s Python interpreter:
Python 2.7.10 |Anaconda 2.3.0 (64-bit)| (default, May 28 2015, 17:02:03) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
Here’s some documentation on how to set up some popular IDEs for Anaconda: https://docs.anaconda.com/anaconda/user-guide/tasks/integration
Installing Brian 2¶
The provided Brian 2 packages are only for 64bit systems. Operating systems running 32bit are no longer officially supported, but Installation with pip might still work.
You can either install Brian 2 in the Anaconda root environment, or create a new environment for Brian 2 (https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html). The latter has the advantage that you can update (or not update) the dependencies of Brian 2 independently from the rest of your system.
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
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). To install them from anaconda, simply do:
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. You can
install it with pip or anaconda, similar to Brian 2 itself (but as of now, it is
not included in the
conda-forge channel, you therefore have to install it
from our own
brian-team channel), e.g. with:
conda install -c brian-team brian2tools
If you decide not to use Anaconda, you can install Brian 2 from the Python package index: https://pypi.python.org/pypi/Brian2
To do so, use the
pip install brian2
You might want to add the
--user flag, to install Brian 2 for the local user
only, which means that you don’t need administrator privileges for the
Note that when installing
brian2 from source with pip, support for using
numerical integration with the GSL requires a working
installation of the GSL development libraries (e.g. the package
on Debian/Ubuntu Linux).
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.
Cython will be automatically installed if you perform the installation via
Anaconda, as recommended. Otherwise you can install them in the usual way, e.g.
pip install cython.
Linux and OS X¶
On Linux and Mac OS X, the conda package will automatically install a C++ compiler.
But even if you install Brian from source, you will most likely already have a
working C++ compiler installed on your system (try calling
in a terminal). If not, use your distribution’s package manager to install a
Install the Microsoft Build Tools for Visual Studio 2017.
- Make sure that your
setuptoolspackage has at least version 34.4.0 (use
conda update setuptoolswhen using Anaconda, or
pip install --upgrade setuptoolswhen using pip).
- Make sure that your
For Standalone code generation, you can either use the compiler installed above or any other version of Visual Studio – in this case, the Python version does not matter.
Try running the test suite (see Testing Brian below) after the installation to make sure everything is working as expected.
To run the latest development code, 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
Another option is to use
pip to directly install from github:
pip install https://github.com/brian-team/brian2/archive/master.zip
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.