Installation¶
Elephant is published on PyPI. You can install it in one of two ways:
Project-based (recommended for new users): a tool such as uv or pixi manages a project folder for you. The folder holds a manifest listing your dependencies and a lock file recording their exact versions, so your analysis can be reproduced later or on another machine.
Environment-based (the traditional workflow): you create a virtual environment yourself, activate it, and install Elephant into it with
piporconda. Use this to add Elephant to an environment you already have, for example a Jupyter kernel or an environment on a cluster.
Getting Elephant¶
Elephant requires Python 3.10 or newer; it is tested with Python 3.10 to 3.14. uv and pixi install a suitable Python for you.
Create a project and add Elephant to it:
uv init my-analysis cd my-analysis uv add elephant
Run Python or your scripts in the project environment:
uv run python uv run my_script.py
To use the advanced features of Elephant, add it with extras
instead: uv add "elephant[extras]".
pixi installs packages from conda-forge. Elephant itself is
not on conda-forge, so it is added from PyPI with --pypi.
Create a project, add Python and Elephant to it:
pixi init my-analysis cd my-analysis pixi add python pixi add --pypi elephant
Run Python or your scripts in the project environment:
pixi run python pixi run python my_script.py
To use the advanced features of Elephant, add it with extras
instead: pixi add --pypi "elephant[extras]".
Create a virtual environment in the folder
.venv:python -m venv .venv
Activate the environment:
# Linux / macOS source .venv/bin/activate # Windows (PowerShell or cmd) .venv\Scripts\activate
Install Elephant:
pip install elephant
With uv installed, uv venv and uv pip install elephant
do the same.
See Installation options for extras, upgrades and the development version.
Create your conda environment (e.g.,
elephant):conda create --name elephant python=3.13
Activate your environment:
conda activate elephant
Install Elephant from PyPI (it is not on conda-forge):
pip install elephant
See Installation options for extras, upgrades and the development version.
Installation options¶
The commands below use pip in an activated environment. In a uv or pixi
project, use uv add or pixi add --pypi instead of pip install.
The easiest way to install Elephant is via pip:
pip install elephant
If you want to use advanced features of Elephant, install the package with extras:
pip install elephant[extras]
To upgrade to a newer release use the --upgrade flag:
pip install --upgrade elephant
If you do not have permission to install software systemwide, you can
install into your user directory using the --user flag:
pip install --user elephant
If you have Git installed on your system, it is also possible to install the development version of Elephant.
Before installing the development version, you may need to uninstall the previously installed version of Elephant:
pip uninstall elephant
Clone the repository and install the local version:
git clone git://github.com/NeuralEnsemble/elephant.git cd elephant
pip install -e .
conda remove -n elephant --all # remove the previous environment
conda env create -f requirements/environment.yml
conda activate elephant
pip install -e .
MPI support¶
Some Elephant modules (ASSET, SPADE, etc.) are parallelized to run with MPI.
In order to make use of MPI parallelization, you need to install mpi4py
package:
conda install -c conda-forge mpi4py
sudo apt install -y libopenmpi-dev openmpi-bin
pip install mpi4py
To run a python script that supports MPI parallelization, run in a terminal:
mpiexec -n numprocs python -m mpi4py pyfile [arg] ...
For more information, refer to mpi4py documentation.
CUDA and OpenCL support¶
Analysis of Sequences of Synchronous EvenTs (ASSET) module supports CUDA and OpenCL. These are experimental features. You can have one, both, or none installed in your system.
To leverage CUDA acceleration on an NVIDIA GPU card, CUDA toolkit must installed on your system. Then run the following command in a terminal:
pip install pycuda
In case you experience issues installing PyCUDA, this guide offers a step-by-step installation manual.
If PyCUDA is detected and installed, CUDA backend is used by default in
Elephant ASSET module. To turn off CUDA support, set ELEPHANT_USE_CUDA
environment flag to 0.
If you have a laptop with a built-in Intel Graphics Card, you can still leverage significant performance optimization with OpenCL backend. The simplest way to install PyOpenCL is to run a conda command:
conda install -c conda-forge pyopencl intel-compute-runtime
However, if you have root (sudo) privileges, it’s recommended to install up-to-date Intel Graphics Compute Runtime system-wide and then install PyOpenCL as follows:
conda install -c conda-forge pyopencl ocl-icd-system
Set ELEPHANT_USE_OPENCL environment flag to 0 to turn off
PyOpenCL support.
Note
Make sure you’ve disabled GPU Hangcheck as described in the Intel GPU developers documentation. Do it with caution - using your graphics card to perform computations may make the system unresponsive until the compute program terminates.
Resolving compilation issues¶
Some modules in Elephant make use of C extensions to speed up computation. However, those extensions need to be compiled before use. In some cases, this causes problems. For example, the compiler on the current machine does not fulfill the requirements for the extension, certain libraries are missing, or no compiler is available at all.
In order to circumvent this problem, the following commands allow to avoid the compilation for specific or for all C extensions.
Use the following to install elephant without C extensions:
pip install elephant --install-option='--no-compile'
To avoid compilation of the c++ extension fim.cpp used in Spike Pattern Detection and Evaluation (SPADE), install the package with:
pip install elephant --install-option='--no-compile-spade'
In this case the pure python implementation of Spike Pattern Detection and Evaluation (SPADE) is still available.
Dependencies¶
Elephant relies on two special packages, installed by default:
quantities - support for physical quantities with units (mV, ms, etc.)
neo - electrophysiology data manipulations