GNU/Linux & macOS#
Prerequisites#
To use PyBaMM, you must have Python 3.10, 3.11, 3.12, 3.13 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.10, 3.11, 3.12, 3.13.
To create a virtual environment env within your current directory type:
virtualenv env
or use any of your preferred environment management tools. 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 or conda.
library beforehand.
pip install pybamm
conda install -c conda-forge pybamm-base
PyBaMM’s required dependencies
(such as numpy, casadi, etc) will be installed automatically when you
install pybamm using pip or pybamm-base using conda.
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’s full conda-forge distribution (pybamm) includes jax and jaxlib by default.
Uninstall PyBaMM#
PyBaMM can be uninstalled by running
pip uninstall pybamm
in your virtual environment.