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.
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
For faster dependency resolution, use mamba:
mamba create -n grass -c conda-forge grass
mamba activate grass
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
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
After activating the conda environment, start GRASS from the command line:
grass