Skip to main content
Skip table of contents

Getting Started with the GastroPlusAPI Python Package

Introduction

This document details the steps for getting started interacting with the GastroPlus Orchestrator Service from Python. It walks through setting up your Python environment, configuring VS Code, and running the example Jupyter notebooks that accompany the GastroPlusAPI Python package.

Full reference documentation for the GastroPlus Orchestrator Service can be found in its own documentation set; this guide is focused solely on first‑time use/ setup of the Python package.

Requirements

To follow along you will need:

  • GastroPlus 10.2 or later installed and licensed.

  • Python ≥ 3.7 (tested with 3.11 & 3.12).

  • Ability to install Python packages (either globally or in a virtual environment).

Installing the GastroPlusAPI Python Package

After installing GastroPlus, the Python-related files are located in:

C:/ProgramData/Simulations Plus, Inc/GastroPlusOrchestrator/10.2/Python

Throughout this guide that path is referred to as <OrchestratorPython>.

The GastroPlus Orchestrator folder, C:/ProgramData/Simulations Plus, Inc/GastroPlusOrchestrator/10.2 will be referred to as <Orchestrator>

Create and Activate a Virtual Environment

BASH
# create a working folder (optional)
mkdir %USERPROFILE%\GastroPlusPython
cd %USERPROFILE%\GastroPlusPython

# create the virtual environment
python -m venv gastro-env

# activate it (Windows)
gastro-env\Scripts\activate.bat

Once activated the prompt will be prefixed with (gastro-env). To deactivate later run deactivate.

activated_gastro-env.png

Appearance of command prompt after ‘gastro-env’ virtual environment has been activated

Install the GastroplusAPI Python Package

BASH
pip install "C:/ProgramData/Simulations Plus, Inc/GastroPlusOrchestrator/10.2/Python/gastroplusapi-10.2.0-py3-none-any.whl"

Install Examples’ Module Dependencies

BASH
pip install -r "C:/ProgramData/Simulations Plus, Inc/GastroPlusOrchestrator/10.2/Python/ExampleScripts/requirements.txt"

Installing and Configuring VS Code

Install VS Code

Download and install Visual Studio Code (. It will install in your own AppData folder; no administrator rights required).

Recommended VS Code Extensions

VSCode has a robust collection of extensions the add capabilities to the IDE depending on your needs. For this we will add the following extensions

Extension

Publisher

Python

Microsoft

Jupyter

Microsoft

Markdown All in One

Yu Zhang

Data Wrangler

Microsoft

Install extensions via File› Preferences › Extensions or Ctrl + Shift + X.

Set VS Code to Use the Python Virtual Environment

  1. Open the Command Palette (Ctrl + Shift + P).

  2. Select Python: Select Interpreter.

  3. Choose Enter interpreter path…Browse….

  4. Navigate to GastroPlusPython\gastro-env\Scripts\python.exe and select it.

The status bar should now show the gastro-env interpreter.

Running the Example Notebooks

Copy the following folders to your working directory so you can freely modify them:

CODE
<OrchestratorPython>\ExampleScripts
<Orchestrator>\ProjectFiles

The ExampleScripts folder contains both Jupyter notebooks (*.ipynb) and rendered web versions (*.html) of each example:

Notebook

What it Demonstrates

Batch_Simulations_Run

Runs an existing batch simulation and plots results

Import_Export_Assets

Import and Export assets from and to a project

GetSetObservedData

Imports observed data from Excel into a project

Using the Notebooks

  1. Open an example notebook (e.g. Batch_Simulations_Run.ipynb) in VS Code.

  2. At the top‑right select the kernel drop‑down and choose Select Another Kernel….

  3. Pick the gastro-env environment from Python Environments.

  4. Execute cells sequentially with Shift + Enter, or run all cells via Run All.

Cells can be executed out of order, provided their dependencies (e.g. opened projects) have been satisfied.

The ExampleScripts folder also includes html-rendered versions of the Jupyter notebooks.

Documentation & Further Reading

Markdown‑based API reference is available in <OrchestratorPython>\Documentation. You can view it:

  • Directly in VS Code (Markdown preview).

  • In any browser with a Markdown extension.

Jupyter Notebooks in VS Code

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.