GNU/Linux & macOS#

Prerequisites#

To use PyBaMM, you must have Python 3.8, 3.9, 3.10, 3.11, or 3.12 installed.

To install Python 3 on Debian-based distributions (Debian, Ubuntu), open a terminal and run

sudo apt-get update
sudo apt-get install python3

On macOS, you can use the homebrew package manager. First, install brew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

then follow instructions in the link on adding brew to path, and run

brew install python

Install PyBaMM#

User install#

We recommend to install PyBaMM within a virtual environment, in order not to alter any distribution Python files. First, make sure you are using Python 3.8, 3.9, 3.10, 3.11, or 3.12. To create a virtual environment env within your current directory type:

virtualenv env

You can then “activate” the environment using:

source env/bin/activate

Now all the calls to pip described below will install PyBaMM and its dependencies into the environment env. When you are ready to exit the environment and go back to your original system, just type:

deactivate

PyBaMM can be installed via pip. On macOS, it is necessary to install the SUNDIALS library beforehand.

In a terminal, run the following command:

pip install pybamm

In a terminal, run the following command:

pip install pybamm

PyBaMM’s required dependencies (such as numpy, casadi, etc) will be installed automatically when you install PyBaMM using pip.

For an introduction to virtual environments, see (https://realpython.com/python-virtual-environments-a-primer/).

Optional - JaxSolver#

Users can install jax and jaxlib to use the Jax solver.

pip install "pybamm[jax]"

The pip install "pybamm[jax]" command automatically downloads and installs pybamm and the compatible versions of jax and jaxlib on your system. (pybamm_install_jax is deprecated.)

Uninstall PyBaMM#

PyBaMM can be uninstalled by running

pip uninstall pybamm

in your virtual environment.