In OGS we make use of Python packages at different stages, e.g.:
Python packages are usually installed via pip inside an isolated environment (a virtual environment).
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.
Make sure, that you did
sudo apt-get install python3 python3-pip
sudo apt-get install python3-venvthen you can use the -DOGS_USE_PIP=ON option:
cmake ../ogs -DOGS_USE_PIP=ON -DCMAKE_BUILD_TYPE="Release" -G NinjaWhen 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.
For example, ogstools or Jupyter will this way be available ready-made in a
consistent configuration.
You can see the current environment definition with all the included packages in
the file requirements.txt inside your build-directory.
When you want to use the python packages in this virtual environment, you need to activate it by
source <your-build-dir>/.envrcwhere .envrc is a little script including source .venv/bin/activate as well as some path settings.
To manually add Python packages run the following inside your build-directory:
.venv/bin/pip install python-package-nameTo activate the environment run source .envrc 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.
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.147.9
in CI job 639840
|
Last revision: September 27, 2025
Commit: [cmake] Remove linker warnings when building mpmetis. 852270d
| Edit this page on