Python environment

In OGS we make use of Python packages at different stages, e.g.:

  • TESPy for simulating thermal engineering plants in a benchmark
  • pvpython for pre- and post-processing
  • nbconvert for testing Jupyter Notebooks

Python packages are usually installed via pip inside an isolated environment (a virtual environment).

Pip

When configuring OGS with OGS_USE_PIP=ON Python creates a new virtual environment in the .venv-directory inside your build directory. It will also install required Python packages into this environment. You can see the current environment definition in the file requirements.txt inside your build-directory.

To manually add Python packages run the following inside your build-directory:

.venv/bin/pip install python-package-name

To activate the environment run source .venv/bin/activate inside your build directory. If you have the direnv-tool installed and setup the virtual environment will be activated automatically upon changing into the build directory.

Pip & Benchmarks

You can use the argument PYTHON_PACKAGES on AddTest() to specify additional Python package dependencies.

The following example would install the latest version of numpy and pandas version 0.1.2:

AddTest(
    ...
    PYTHON_PACKAGES numpy pandas==0.1.2
    ...
)

This article was written by Lars Bilke. If you are missing something or you find an error please let us know.
Generated with Hugo 0.122.0 in CI job 430699 | Last revision: April 9, 2024
Commit: Removed container-maker references. 8cef567  | Edit this page on