Installation¶
sleap-io can be used as a CLI tool, a Python library, or a dependency of another package. Choose the installation method that best fits your use case.
Quick Start¶
Run commands without installing anything:
Requires uv. See CLI Reference for available commands.
Use Cases¶
As a CLI utility for working with pose data¶
Use sleap-io to inspect, convert, and manipulate pose tracking files from the command line.
One-off usage (no installation)¶
The fastest way to use sleap-io is with uvx, which runs CLI tools in temporary isolated environments:
# Inspect a labels file
uvx sleap-io show labels.slp
# Convert between formats
uvx sleap-io convert -i labels.slp -o labels.nwb
# Use with all optional dependencies (requires --from for extras)
uvx --from "sleap-io[all]" sleap-io show labels.slp
This is ideal for:
- Quick one-off conversions
- CI/CD pipelines
- Trying sleap-io without installing
Installing uv
If you don't have uv, install it with:
System-wide installation¶
For regular use, install sleap-io as a global tool:
After installation, use either sio or sleap-io as the command:
The [all] extra
The [all] extra includes faster video backends (OpenCV, PyAV) and additional format support. You can omit it for a minimal installation:
Video support via imageio-ffmpeg is always included. The [all] extra also
includes the cloud-storage adapters (s3fs, gcsfs, adlfs) needed to
load .slp files from s3:///gs:///az:// URLs. Loading remote media
video over http/https additionally needs a PyAV backend ([all] or
[pyav]) — see Remote video.
See the CLI documentation for a complete command reference.
As a Python utility library for manipulating pose data¶
Use sleap-io programmatically to load, manipulate, and save pose tracking data.
In a project environment¶
From source (latest development version)¶
For environments not managed by uv:
For quick installation into an existing virtual environment:
Quick usage example¶
# /// script
# dependencies = ["sleap-io[all]"]
# ///
import sleap_io as sio
# Load labels from any supported format
labels = sio.load_file("labels.slp")
# Inspect the data
print(f"Videos: {len(labels.videos)}")
print(f"Labeled frames: {len(labels.labeled_frames)}")
print(f"Skeleton: {labels.skeleton.node_names}")
# Convert to numpy for analysis
locations = labels.numpy() # shape: (frames, tracks, nodes, 2)
# Save to a different format
sio.save_nwb(labels, "labels.nwb")
Run directly with uv (no installation needed):
See Examples for more usage patterns.
As a dependency of another package or tool¶
Add sleap-io to your project's dependencies for pose data I/O.
In pyproject.toml¶
From source (Git dependency)¶
For development versions or unreleased features:
Pinning specific versions¶
For reproducible builds, pin to a specific version or commit:
# Pin to version
"sleap-io[all]==0.6.0"
# Pin to specific commit
"sleap-io[all] @ git+https://github.com/talmolab/sleap-io.git@abc1234"
# Pin to tag
"sleap-io[all] @ git+https://github.com/talmolab/[email protected]"
As a developer looking to extend capabilities¶
Set up a development environment to contribute to sleap-io or add new format support.
Clone and install¶
# Clone the repository
git clone https://github.com/talmolab/sleap-io.git
cd sleap-io
# Install with development dependencies (recommended)
uv sync --all-extras
This installs:
- All optional dependencies (
opencv,pyav,mat,polars,cloud) - Development tools (
pytest,ruff,mkdocs) - The package in editable mode
Alternative installation methods¶
pip install -e ".[all]" # runtime + optional extras
pip install --group dev # dev tools (pytest, ruff, mkdocs)
Note
dev is a PEP 735 dependency-group,
not a pip extra — pip install -e ".[dev,all]" installs [all] but
silently skips the dev tools (pip warns and ignores the unknown dev
extra). Install the group separately with pip install --group dev.
Running tests¶
# Run all tests
pytest
# Run with coverage
pytest --cov=sleap_io
# Run specific test file
pytest tests/io/test_slp.py
Code style¶
Building documentation¶
See CLAUDE.md for detailed development guidelines.
Optional Dependencies¶
sleap-io uses optional dependencies for specific features:
| Extra | Packages | Purpose |
|---|---|---|
opencv |
opencv-python |
Fastest video backend (2-3x faster) |
pyav |
av |
Balanced speed/features video backend; required for loading remote media video over http/https |
cloud |
s3fs, gcsfs, adlfs |
Load .slp from cloud-storage URLs (s3://, gs:///gcs://, az:///abfs://) |
mat |
pymatreader |
LEAP .mat file support |
polars |
polars, pyarrow |
Fast dataframe operations |
all |
All of the above | Everything included |
http/https URLs — including Google Drive share links — work with the base
install; cloud-storage URLs need the cloud extra and remote media video needs
the pyav extra. See the Remote loading guide.
Install specific extras:
pip install "sleap-io[opencv]" # Just OpenCV
pip install "sleap-io[opencv,mat]" # Multiple extras
pip install "sleap-io[all]" # Everything
Default video support
Video reading works out of the box via imageio-ffmpeg, which is always installed. The optional video backends provide faster performance or additional codec support.
OpenCV dependency conflicts
The opencv-python package can cause dependency conflicts in environments with other packages that also depend on OpenCV (e.g., some ML frameworks install opencv-python-headless). If you encounter conflicts, install without the opencv extra:
The pyav backend provides good performance without the conflict risk.
Upgrading¶
CLI tool (uv tool)¶
Python package¶
From source¶
Or reinstall:
Uninstalling¶
CLI tool (uv tool)¶
Python package¶
Troubleshooting¶
Video backends not found¶
Check installed backends:
sio --version
# Or in Python:
python -c "import sleap_io; print(sleap_io.get_available_video_backends())"
Install missing backends:
Import errors¶
Ensure you're in the correct environment:
Permission issues with uv tool¶
Use --python to specify a Python version:
Conflicting dependencies¶
Create a fresh environment:
See Also¶
- CLI Reference: Complete command documentation
- Examples: Python usage patterns
- Formats: Supported file formats
- Changelog: Version history