Installation

apsimNGpy is under active development. Stable releases are available, but new features and bug fixes are introduced frequently. You can install the package using one of the methods below.

Installing apsimNGpy

Method 1: Install from PyPI (stable releases)

pip install apsimNGpy

Method 2: Clone the development repository

git clone https://github.com/MAGALA-RICHARD/apsimNGpy.git
cd apsimNGpy
pip install .

Editable installation (for developers)

git clone https://github.com/MAGALA-RICHARD/apsimNGpy.git
cd apsimNGpy
pip install -e .

Prerequisites

Important

Before using apsimNGpy, APSIM Next Generation must be installed.

apsimNGpy assumes users have a basic understanding of APSIM as a process-based crop model. The goal of this package is to provide a programmatic and reproducible interface.

Tip

Use the pinned APSIM release shown on the apsimNGpy home page (Download it here) to avoid forward-compatibility issues.

Verifying the APSIM Binary Path

Using the command line

apsim_bin_path -s

Using Python

from apsimNGpy.core import config
print(config.get_apsim_bin_path())

See also

API reference: get_apsim_bin_path()

How apsimNGpy Locates APSIM Binaries

Tip

apsimNGpy locates APSIM binaries using the following priority order:

  1. User-supplied binary path

  2. Environment variables

  3. System PATH

  4. Known installation directories

If no valid path is found, a ValueError is raised.

Setting or Updating the APSIM Binary Path

Option 1: Manual configuration file

  1. Locate APSIMNGpy_meta_data in your home directory.

  2. Open apsimNGpy_config.ini.

  3. Update the apsim_location entry.

Option 2: Environment variable (temporary)

import os
os.environ["APSIM"] = r"path/to/your/apsim/binary/folder/bin"

Caution

This approach must be executed before importing apsimNGpy.

Option 4: Command-line update

apsim_bin_path -u "path/to/your/apsim/binary/folder/bin"

or

apsim_bin_path --update "path/to/your/apsim/binary/folder/bin"

Verifying Successful Configuration

from apsimNGpy.core.apsim import ApsimModel

Attention

If this import fails, verify the APSIM binary path and Python.NET setup.

Final Note

The APSIM binary path only needs to be set once and can be reused across projects. apsimNGpy also supports switching between multiple APSIM versions when required.

Containerization and Portability

apsimNGpy simplifies containerization and project portability. Entire projects can be transferred to another machine without reinstalling APSIM, provided the APSIM binaries are correctly referenced.