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.
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
The same works with mamba for faster dependency resolution:
mamba install -c conda-forge 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
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
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
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
After activating the conda environment, start GRASS from the command line:
grass