Additional Python packages¶
Python is a language with an extensive ecosystem of additional packages that can be used for various things. Here we list some key packages which can be useful for doing modelling.
Due to the vast amount of packages available, and different packages using different versions, we strongly recommend working in a virtual environment. You can find more on that in the virtual environment page.
Installing additional packages¶
Additional package are typically installed using pip
from the pypi.org repository. Simply run
uv add packagename
packagename
is the name of the package you want to install (e.g. numpy
).
No pyproject.toml
found in current directory or any parent directory
If you get this error, you need to initialize the uv environment before installing packages:
uv init
or alternatively, create the pyproject.toml
file manually.
pip install packagename
Where packagename
is the name of the package you want to install (e.g. numpy
).
It is also possible to install a group at the same time. One common method of grouping packages for a project is a so-called requirements file (often named requirements.txt
). To do this, run
uv add -r requirements.txt
pyproject.toml
fileuv sync
pip install -r requirements.txt
pip freeze > requirments.txt
NumPy and SciPy¶
NumPy and SciPy are staples when it comes to scientific computing in Python. You can install them using pip:
uv add numpy scipy
pip install numpy scipy
SUND¶
The SUND (Simulation Using Nonlinear Dynamic models) package is a package for simulating ODE models inspired by the MATLAB package IQM. It features a simple syntax for writing the model, and is able to combine models in a modular way by exposing inputs/outputs between models. It is also possible to give inputs in the form of predefined activities, which can contain constant outputs as well as more complex piecewise or interpolated outputs.
The easiest way is to install the sund package using pip:
uv add https://isbgroup.eu/sund-toolbox/releases/sund-latest.tar.gz
pip install https://isbgroup.eu/sund-toolbox/releases/sund-latest.tar.gz
It can then be used by importing the package sund
:
import sund
If the compiler is not found by setuptools (typically not a problem)
If you get problems that the compiler is not found (even if you have installed the compiler), sometimes it helps to upgrade setuptools
and then try to install the package again:
bash
uv add --upgrade setuptools
pip install --upgrade setuptools
AMICI (not currently used for the courses on this page)¶
AMICI is a package for simulating ODE models specified in the SBML format. It is using C in the background, and is able to both simulate the model and do parameter estimation.
For installing AMICI, we refer to the official install instructions available here.