# Installation¶

To solve the exercises you need to install Python, the Brian2 simulator and the neurodynex3 package. The tutorial below will explain two different ways of installing everything:

• using the pip package manager (Linux, macOS)
• using the conda package manager, if you have Anaconda installed (Linux, macOS, Windows).

In both cases, we will use the package manager to create a virtual environment called bmnn and install everything there.

## Using pip¶

1. We will start by creating a virtual environemt that contains a separate Python installation. To do this, we first need the virtualenv package. Install this by running:

>> pip install virtualenv

2. Now create the virtual environment in a folder called bmnn:

>> virtualenv bmnn

3. Activate the virtual environment:

>> source bmnn/bin/activate

4. Now install neurodynex3 and all its requirements:

>> pip install --upgrade neurodynex3

5. You can now use Python in this environment as you normally would. Move to the folder where you want your code to be stored and start a Jupyter notebook by running:

>> cd your_folder
>> jupyter notebook

6. Finally, when you are done using the virtual environment, you can deactivate it:

>> deactivate


Note

If something goes wrong inside the virtual environment, you can simply delete it by removing its folder (with the regular rm -r command) and start over:

>> deactivate
>> rm -r bmnn


## Using conda¶

Anaconda is a Python distribution that can be installed on Linux, macOS, and Windows. It comes together with a package manager called conda. To run conda commands if you are using Windows, first start the Anaconda Prompt.

If you are using Linux or macOS, you can run conda commands in a regular terminal.

1. We start by creating a virtual environemt that contains a separate Python installation. The virtual environment is called bmnn:

>> conda create --name bmnn python

2. Activate the virtual environment:

>> conda activate bmnn

3. Now install required Python packages:

>> conda install numpy scipy jupyter matplotlib mpmath setuptools setuptools_scm mock nose

4. Install Brian2:

>> conda install -c conda-forge brian2

5. We will now install neurodynex3. Note: this step is done using pip, not conda. First make sure that you are using pip inside the virtual environment:

>> pip --version
pip 20.0.2 from //anaconda3/envs/bmnn/.../pip (python 3.8)

6. Now run the install command:

>> pip install neurodynex3

7. You can now use Python in this environment as you normally would. Move to the folder where you want your code to be stored and start a Jupyter notebook by running:

>> cd your_folder
>> jupyter notebook

8. Finally, when you are done using the virtual environment, you can deactivate it:

>> conda deactivate


Note

If something goes wrong inside the virtual environment, you can simply delete it and start over:

>> conda deactivate
>> conda remove --name bmnn --all


## Start a Jupyter notebook¶

1. First, activate the virtual environment. If you use pip, activate the virtual environment with

>> source bmnn/bin/activate


If you use conda, activate the virtual environment with:

>> conda activate bmnn


Note

Always make sure you use programs that are inside the virtual environment. To see that you are using the jupyter that is inside the bmnn virtual environment on Linux/macOS, you can use the which command

>> which jupyter
.../bmnn/bin/jupyter


and on Windows you can use the where command

> where jupyter
C:\...\Anaconda3\envs\bmnn\jupyter.exe

2. Move to the folder where you want your code to be stored and start a Jupyter notebook:

>> cd your_folder
>> jupyter notebook

3. Starting Jupyter will open your browser. Select New, Python3 to get a new notebook page. Depending on what else you have installed on your computer, you may have to specify the kernel.

4. Once you have created a new notebook, copy-paste the code of the exercise into the notebook and run it. Note that the first time you do this, the execution may take a little longer and, in some cases, you may see compilation warnings.

We recommend you to create one notebook per exercise.