Follow us on YouTube. Support us through NumFOCUS.

GRASS for conda

The grass package is available on conda-forge for Linux (64-bit) and macOS (Intel and Apple Silicon). See the conda-forge grass feedstock for packaging details.

Install with conda

Create a new environment and install GRASS:

conda create -n grass -c conda-forge grass
conda activate grass

Or install into an existing environment:

conda install -c conda-forge grass

Install with mamba

For faster dependency resolution, use mamba:

mamba create -n grass -c conda-forge grass
mamba activate grass

Environment file

To create a reproducible environment, save the following as environment.yml:

name: grass
channels:
  - conda-forge
dependencies:
  - grass

Then create the environment with:

conda env create -f environment.yml
conda activate grass

Usage

Python

To use GRASS in Python scripts, add the GRASS Python package path to sys.path:

import subprocess
import sys

result = subprocess.run(["grass", "--config", "python_path"],
                        check=True, text=True, capture_output=True)
sys.path.append(result.stdout.strip())

import grass.script as gs

Command line

After activating the conda environment, start GRASS from the command line:

grass