--- id: sh version: "2.4.0" license: MIT license_treatment: permissive maintenance: active --- # sh — Python subprocess replacement License: permissive · Maintenance: active · Downloads: 12.2M/mo ## What it is and what it does sh is a subprocess wrapper that lets you import and call Unix programs directly as Python functions, eliminating the need to construct command strings or manage subprocess objects manually. Instead of writing subprocess code, you write `from sh import git; git('status', '--short')`. The package is designed for Unix-like systems only (Linux, macOS, BSD) and does not support Windows. It works by dynamically creating callable objects that map to system programs and handling the underlying process spawning, argument passing, and output capture. With no external dependencies and a pure-Python implementation, it installs cleanly and runs on Python 3.10 through 3.14 and PyPy. The interface is intentionally simple: it is not a reimplementation of Unix tools in Python, but a thin layer that makes calling existing programs feel native to Python code. Use it for: - Automating git workflows in deployment or CI scripts by calling git commands directly as functions. - Building command-line tools that orchestrate multiple system utilities without subprocess boilerplate. - Writing system administration scripts that invoke tools like grep, sed, or find with natural Python syntax. - Testing shell scripts or system behavior from Python test suites by invoking the actual programs. - Capturing and processing output from external programs in data pipelines or build systems. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Calls any Unix program as a Python function, replacing subprocess with a simpler interface that treats external commands as callable objects. Yes. sh is actively maintained, has no dependencies, installs with low friction, carries no known vulnerabilities, and solves a real pain point in subprocess handling. Install it if you regularly call Unix programs from Python and prefer a cleaner syntax than subprocess. Not applicable on Windows. ## Install pip install sh uv add sh poetry add sh ## Installing sh Before you install: Low friction—pure Python wheel with no runtime dependencies. Actively maintained with a recent release (20 days ago) and 7245 repository stars. License in practice: MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions. Quickstart: pip install sh from sh import git print(git("status", "--short")) Unix-like operating system required (Linux, macOS, BSD); Windows is not supported. Verify before relying: - Whether the package handles shell metacharacters and escaping automatically or requires manual quoting. - Performance characteristics compared to subprocess.run() for high-volume command execution. - Behavior when called programs write to stderr or exit with non-zero status codes. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 12.2M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags subprocess replacement, call unix commands from python, shell command wrapper, python subprocess alternative, execute external programs, unix system calls python, command line interface wrapper, subprocess, unix-only, cli-wrapper [View on SkillFed](https://skillfed.io/packages/sh) · [View on PyPI](https://pypi.org/project/sh/)