Installation

The following steps work installing the dependencies in Linux via apt-get or in macOS using brew or macports. While using packages managers such as Anaconda, Miniforge, or Mamba might work, these are not tested. The supported Python versions are 3.12 to 3.14.

Python package

To install the pyopmnearwell executable from the development version:

pip install git+https://github.com/cssr-tools/pyopmnearwell.git

If you are interested in a specific version (e.g., v2025.10) or in modifying the source code, then you can clone the repository and install the Python requirements in a virtual environment with the following commands:

# Clone the repo
git clone https://github.com/cssr-tools/pyopmnearwell.git
# Get inside the folder
cd pyopmnearwell
# For a specific version (e.g., v2025.10), or skip this step (i.e., edge version)
git checkout v2025.10
# Create virtual environment
python3 -m venv vpyopmnearwell
# Activate virtual environment
source vpyopmnearwell/bin/activate
# Upgrade pip, setuptools, and wheel
pip install --upgrade pip setuptools wheel
# Install the pyopmnearwell package
pip install -e .
# For contributions/testing/linting, install the dev-requirements
pip install -r dev-requirements.txt

Tip

Typing git tag -l writes all available specific versions.

Note

The tensorflow package has been removed from the dependencies to allow for a ligther installation of pyopmnearwell. Most of the functionality in pyopmnearwell can be used without having installed tensorflow, i.e., running in the terminal pyopmnearwell -i configuration_file.toml does not require tensorflow. The tensorflow package is a requirement only for the machine learning near well functionality, see the ML_near_well repository. If you are interested in the ML functionality and using Python 3.12 or 3.13, then after installing pyopmnearwell, install tensorflow by executing in the terminal

pip install tensorflow

Currently tensorflow is not available via pip in Python 3.14 (we will update this when it is available).

OPM Flow

You also need to install:

Tip

See the CI.yml script for installation of OPM Flow (binary packages) and the pyopmnearwell package in Ubuntu.

Source build in Linux/Windows

If you are a Linux user (including the Windows subsystem for Linux, see this link for a nice tutorial for setting Python environments in WSL), then you could try to build Flow (after installing the prerequisites) from the master branches with mpi support by running in the terminal the following lines (which in turn should build flow in the folder ./build/opm-simulators/bin/flow):

CURRENT_DIRECTORY="$PWD"

mkdir build

for repo in common grid
do  git clone https://github.com/OPM/opm-$repo.git
    mkdir build/opm-$repo
    cd build/opm-$repo
    cmake -DUSE_MPI=1 -DWITH_NDEBUG=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid" $CURRENT_DIRECTORY/opm-$repo
    if [[ $repo == simulators ]]; then
        make -j5 flow
    else
        make -j5 opm$repo
    fi
    cd ../..
done

Tip

You can create a .sh file (e.g., build_opm_mpi.sh), copy the previous lines, and run in the terminal source build_opm_mpi.sh

Source build in macOS

For macOS, there are no available binary packages, so OPM Flow needs to be built from source, in addition to the dune libraries (see the prerequisites, which can be installed using macports or brew). For example, with brew the prerequisites can be installed by:

brew install boost openblas suite-sparse python@3.13 cmake

In addition, it is recommended to uprade and update your macOS to the latest available versions (the following steps have worked for macOS Tahoe 26.1 with Apple clang version 17.0.0). After the prerequisites are installed and the vpyopmnearwell Python environment is created (see Python package), then building OPM Flow can be achieved with the following bash lines:

This can be achieved by the following lines:

CURRENT_DIRECTORY="$PWD"

deactivate
source vpyopmnearwell/bin/activate

for module in common geometry grid istl
do   git clone https://gitlab.dune-project.org/core/dune-$module.git --branch v2.9.1
    ./dune-common/bin/dunecontrol --only=dune-$module cmake -DCMAKE_DISABLE_FIND_PACKAGE_MPI=1
    ./dune-common/bin/dunecontrol --only=dune-$module make -j5
done

mkdir build

for repo in common grid simulators
do  git clone https://github.com/OPM/opm-$repo.git
    mkdir build/opm-$repo
    cd build/opm-$repo
    cmake -DUSE_MPI=0 -DWITH_NDEBUG=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/dune-common/build-cmake;$CURRENT_DIRECTORY/dune-grid/build-cmake;$CURRENT_DIRECTORY/dune-geometry/build-cmake;$CURRENT_DIRECTORY/dune-istl/build-cmake;$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid" $CURRENT_DIRECTORY/opm-$repo
    if [[ $repo == simulators ]]; then
        make -j5 flow
    else
        make -j5 opm$repo
    fi
    cd ../..
done

echo "export PATH=\$PATH:$CURRENT_DIRECTORY/build/opm-simulators/bin" >> $CURRENT_DIRECTORY/vpyopmnearwell/bin/activate

deactivate
source vpyopmnearwell/bin/activate

This builds OPM Flow, and it exports the path to the flow executable (i.e., executing in the terminal which flow should print the path).

Tip

See this repository dedicated to build OPM Flow from source in the latest macOS (GitHub actions).