Installation Guide¶
This guide walks through setting up SWIM-RS from scratch, including dependencies and optional components.
Prerequisites¶
- Python 3.13 (recommended stable version)
- uv (recommended; fastest way to create a clean environment)
- Git (optional; only needed for installing from source)
- conda (optional; can simplify geospatial dependencies)
uv Installation (Recommended)¶
This is the quickest way to get a modern, reproducible environment with SWIM-RS.
1. Create a project and install SWIM-RS¶
If you're starting from scratch:
mkdir swim-rs && cd swim-rs
uv init --python 3.13
uv add git+https://github.com/dgketchum/swim-rs.git
If you already have a pyproject.toml, run:
Optional extras:
If geospatial dependencies fail to install (GDAL/PROJ issues), use the Conda Installation section below or see Install Geospatial Dependencies under Non-Conda Installation for system-library instructions.
2. Install PEST++ binaries (required for calibration)¶
SWIM-RS uses PEST++ for calibration. You can download the executables automatically via pyemu:
3. Add ./bin to your PATH¶
Ensure the pestpp-* executables are discoverable (so the swim CLI can find the PEST++ engine):
Linux/macOS:
Windows (PowerShell):
4. Verify installation¶
Conda Installation (Alternative)¶
1. Install Conda (if needed)¶
If you don't have conda installed, we recommend Miniconda (lightweight) or Miniforge (community-driven, conda-forge default).
Option A: Miniconda¶
Download from: https://docs.conda.io/en/latest/miniconda.html
Windows:
1. Download Miniconda3-latest-Windows-x86_64.exe from the link above
2. Run the installer and follow prompts
3. Open "Anaconda Prompt" from the Start menu for conda commands
Linux:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
macOS (Intel):
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
bash Miniconda3-latest-MacOSX-x86_64.sh
macOS (Apple Silicon):
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh
bash Miniconda3-latest-MacOSX-arm64.sh
Option B: Miniforge (recommended for Apple Silicon and conda-forge defaults)¶
Download from: https://github.com/conda-forge/miniforge
Windows:
1. Download Miniforge3-Windows-x86_64.exe from the releases page
2. Run the installer and follow prompts
3. Open "Miniforge Prompt" from the Start menu
Linux:
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
bash Miniforge3-Linux-x86_64.sh
macOS (Apple Silicon):
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
bash Miniforge3-MacOSX-arm64.sh
After installation:
- Windows: Open Anaconda Prompt or Miniforge Prompt
- Linux/macOS: Restart your terminal or run source ~/.bashrc (or ~/.zshrc)
2. Create a Conda Environment¶
Create a dedicated environment for SWIM-RS. These commands work the same on Windows (Anaconda Prompt), macOS, and Linux:
3. Install PEST++ (for calibration)¶
PEST++ is required for parameter estimation. Install from conda-forge:
Verify installation:
You should see version output like PEST++ Version 5.x.x.
4. Install Geospatial Dependencies¶
Some geospatial libraries install more reliably via conda:
5. Install SWIM-RS¶
From GitHub:
Editable install (for development):
With OpenET models (optional):
To use OpenET algorithm implementations directly (for custom ETf calculations):
Or if installing from source:
6. Set Up Google Earth Engine (optional)¶
Earth Engine access is only needed if you want to extract fresh remote sensing data. The shipped examples include pre-extracted data.
- Go to https://earthengine.google.com/ and sign up
- Run
earthengine authenticateand complete OAuth in browser - Verify with:
python -c "import ee; ee.Initialize(); print('EE OK')"
7. Verify Installation¶
Non-Conda Installation¶
If you prefer not to use conda, you can install SWIM-RS with pip and download PEST++ executables directly.
1. Create a Virtual Environment¶
Linux/macOS:
Windows (PowerShell):
Windows (Command Prompt):
2. Install SWIM-RS via pip¶
Or from source:
3. Install PEST++ Executables¶
PEST++ is required for calibration. Recommended: download the executables automatically via pyemu:
Linux/macOS/Windows (from your activated venv):
Add ./bin to your PATH so swim can find the PEST++ engine:
Linux/macOS:
Windows (PowerShell):
Alternative: download pre-built PEST++ binaries from the official releases:
Download: https://github.com/usgs/pestpp/releases
- Download the appropriate archive for your platform:
- Windows:
pestpp-X.X.X-win.zip - Linux:
pestpp-X.X.X-linux.tar.gz -
macOS:
pestpp-X.X.X-mac.tar.gz -
Extract and add to PATH:
Linux/macOS:
# Example for Linux
wget https://github.com/usgs/pestpp/releases/download/X.X.X/pestpp-X.X.X-linux.tar.gz
tar -xzf pestpp-X.X.X-linux.tar.gz
sudo mv pestpp-X.X.X-linux/bin/* /usr/local/bin/
# Or add to PATH in ~/.bashrc:
# export PATH="$HOME/pestpp-X.X.X-linux/bin:$PATH"
Windows:
1. Extract the zip to a folder (e.g., C:\pestpp)
2. Add to PATH:
- Open System Properties → Environment Variables
- Edit Path under User variables
- Add C:\pestpp\bin
3. Restart your terminal
Verify:
4. Install Geospatial Dependencies¶
Without conda, you may need system libraries for GDAL:
Ubuntu/Debian:
sudo apt-get install gdal-bin libgdal-dev
pip install gdal==$(gdal-config --version)
pip install geopandas rasterio fiona pyproj shapely
macOS (Homebrew):
Windows:
Use pre-built wheels from Christoph Gohlke's archive or try:
Or use the OSGeo4W installer which includes GDAL and Python bindings.
5. Verify Installation¶
Complete Setup Scripts¶
uv (Linux/macOS)¶
#!/bin/bash
mkdir swim-rs && cd swim-rs
uv init --python 3.13
uv add git+https://github.com/dgketchum/swim-rs.git
# Download PEST++ binaries to ./bin
uv run python -c "import pyemu; pyemu.helpers.get_pestpp_binaries(dest_dir='./bin')"
export PATH="$PWD/bin:$PATH"
uv run swim --help && uv run pestpp-ies --version
uv (Windows — PowerShell)¶
mkdir swim-rs
cd swim-rs
uv init --python 3.13
uv add git+https://github.com/dgketchum/swim-rs.git
# Download PEST++ binaries to ./bin
uv run python -c "import pyemu; pyemu.helpers.get_pestpp_binaries(dest_dir='./bin')"
$env:Path = "$PWD\\bin;$env:Path"
uv run swim --help
uv run pestpp-ies --version
Conda (Linux/macOS)¶
#!/bin/bash
conda create -n swim python=3.13 -y && conda activate swim
conda install -c conda-forge pestpp geopandas rasterio pyproj fiona shapely -y
git clone https://github.com/dgketchum/swim-rs.git && cd swim-rs
pip install -e .
swim --help && pestpp-ies --version
Conda (Windows — Anaconda Prompt)¶
conda create -n swim python=3.13 -y && conda activate swim
conda install -c conda-forge pestpp geopandas rasterio pyproj fiona shapely -y
git clone https://github.com/dgketchum/swim-rs.git && cd swim-rs
pip install -e .
swim --help && pestpp-ies --version
Non-Conda (Linux/macOS)¶
#!/bin/bash
python3.13 -m venv ~/.venvs/swim && source ~/.venvs/swim/bin/activate
pip install --upgrade pip
# Install GDAL system library first (Ubuntu: sudo apt-get install gdal-bin libgdal-dev)
pip install geopandas rasterio fiona pyproj shapely
# Install swim-rs
git clone https://github.com/dgketchum/swim-rs.git && cd swim-rs
pip install -e .
# Download PEST++ from https://github.com/usgs/pestpp/releases and add to PATH
swim --help && pestpp-ies --version
Troubleshooting¶
GDAL/Fiona errors¶
If you see GDAL-related errors, ensure geospatial libs are from conda:
PEST++ not found¶
If you're using uv (recommended), download the binaries and ensure ./bin is on your PATH:
uv run python -c "import pyemu; pyemu.helpers.get_pestpp_binaries(dest_dir='./bin')"
export PATH="$PWD/bin:$PATH"
If you're using conda, install via conda-forge:
Earth Engine authentication fails¶
Try re-authenticating with a fresh token:
Import errors after pip install¶
Ensure you're in the correct conda environment:
conda activate swim
which python # Linux/macOS - should point to your conda env
where python # Windows - should point to your conda env
Apple Silicon (M1/M2) issues¶
Use Miniforge instead of Miniconda for better ARM64 support:
Windows: "swim" command not found¶
If you installed with uv, run commands via:
If you installed with conda, ensure you're in the Anaconda/Miniforge Prompt (not regular Command Prompt or PowerShell). Alternatively, use:
Windows: Long path errors¶
Enable long paths in Windows 10/11:
1. Open Group Policy Editor (gpedit.msc)
2. Navigate to: Computer Configuration → Administrative Templates → System → Filesystem
3. Enable "Enable Win32 long paths"
Or via Registry:
Windows: Git not found¶
Install Git for Windows from: https://git-scm.com/download/win
Or install via conda:
Environment File (optional)¶
For reproducible environments, create environment.yml:
name: swim
channels:
- conda-forge
- defaults
dependencies:
- python=3.13
- pestpp
- geopandas
- rasterio
- pyproj
- fiona
- shapely
- numpy
- scipy
- pandas
- xarray
- zarr
- pip
- pip:
- git+https://github.com/dgketchum/swim-rs.git
Install with:
Next Steps¶
- Run the Quick Start example
- Explore the Examples for tutorials and workflows
- Read the Data Extraction Guide if you need to pull fresh EE data