Getting started#

Pharmpy can be used in a Python program as a library or via its command line interface. It can also be used via its R wrapper package: pharmr.

Installation#

Note

If you plan to use Pharmpy in R, please follow the steps in Installing pharmr.

Warning

Pharmpy requires Python 3.10 or later, and is currently tested on Python 3.10, 3.11 and 3.12 on Linux, MacOS and Windows.

Install the latest stable version from PyPI with:

pip install pharmpy-core

To be able to use components using machine learning the tflite package is needed. It can be installed using:

pip install --index-url https://google-coral.github.io/py-repo/ tflite_runtime

A first example#

The pharmpy.model.Model class is representation of a nonlinear mixed effects model. For example, to load an example NONMEM model:

from pharmpy.modeling import load_example_model, print_model_code

model = load_example_model('pheno')
print_model_code(model)

The model file format is automatically detected:

type(model)
pharmpy.model.external.nonmem.model.Model

You can read more about how to read in and examine your model in The Pharmpy model, and how to transform your model via Modeling. We also have several Tools to run more complex workflows.

Note

In order to run any of the tools you need to have a configuration file set up with a path to NONMEM, instructions can be found here.