Follow us on YouTube. Support us through NumFOCUS.

GRASS for conda

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

Install with conda

Add into an existing environment:

conda install -c conda-forge grass

If you don’t have an environment yet, create a new environment and install in one step:

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

Install with mamba

The same works with mamba for faster dependency resolution:

mamba install -c conda-forge grass

Environment file with conda/mamba

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

Install with pixi

For faster dependency across multiple platforms, support for pyproject.toml and environment.yml, and global installation of tools use pixi:

# Installing grass as part of a workspace
pixi init name-of-my-project-using-grass
cd name-of-my-project-using-grass
pixi add grass
# Activates a shell where grass is accessible
pixi shell

If you want to install GRASS as a globally available tool across your system without having to activate an environment:

pixi global install grass

Environment file with pixi

By default, dependencies for the workspace are stored in the pixi.toml file. The pixi.lock file is the machine-readable file that lists all of the dependencies for your workspace.

If you’re using pixi and want to share your environment with conda or mamba users:

pixi workspace export conda-environment environment.yml

Usage

Python

To use GRASS from a Python script in an active conda environment, 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