Python Environments
Inline packages
Append :pkg1,pkg2 to install packages before running:
kapsl [email protected]:requests,jinja2 -c "import requests; print(requests.__version__)"
kapsl [email protected]:numpy,pandas script.py
You can pin package versions using standard pip syntax:
kapsl [email protected]:requests==2.31.0,jinja2>=3.0 script.pyrequirements.txt
kapsl -e @pip:requirements.txt python script.py
kapsl reads the file, builds a pip-based image, caches it, and runs the script. If the file changes, the image is rebuilt on the next run.
With uv
kapsl -e @uv:requirements.txt python script.py
uv is a fast Python package installer. Use it by specifying the @uv provider.
Auto-detect
kapsl -e @pip python script.py # finds requirements.txt in CWDpyproject.toml
kapsl -e @uv:pyproject.toml python script.py
kapsl -e @uv python script.py # auto-detects pyproject.toml or requirements.txtShebang scripts
#!/usr/bin/env -S kapsl [email protected]:requests,jinja2
import requests
from jinja2 import Template
t = Template("Hello, {{ name }}!")
print(t.render(name="world"))chmod +x script.py
./script.py
The shebang pins both the Python version and the packages. The script runs identically on any machine with kapsl installed.
Version matrix
Test against multiple Python versions by running the same command with different tags:
kapsl [email protected]:pytest pytest tests/
kapsl [email protected]:pytest pytest tests/
kapsl [email protected]:pytest pytest tests/