envsubst
Substitute environment variables in a string
What it is and what it does
envsubst is a lightweight utility for performing shell-style environment variable substitution within Python strings. It parses strings containing variable references like `$VAR` or `${VAR}` and replaces them with their corresponding environment variable values. The package supports default value syntax—`${VAR:-default}` uses a default if the variable is unset, and `${VAR-default}` uses a default only if the variable is unset or empty—mirroring common shell behavior.
The package has no runtime dependencies and installs as a pure Python wheel, making it simple to add to any project. However, it has been abandoned since its last release in October 2019, with no commits to the repository since July 2023. This means any bugs or compatibility issues with newer Python versions will not be fixed by the maintainer.
Use it for:
- Substitute environment variables into configuration strings or templates at runtime without external templating libraries.
- Parse and expand shell-like variable references in user-provided strings or configuration files.
- Build dynamic command strings or paths that depend on environment variables with fallback defaults.
- Migrate shell scripts to Python while preserving variable substitution syntax familiar to shell users.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Substitutes environment variables in strings using shell-like syntax, supporting both simple variable references and default value expressions.
Yes, if you need simple shell-style variable substitution and can accept that the package is unmaintained. The low install friction and permissive MIT license make it a lightweight choice for straightforward use cases. No, if you require active maintenance, Python version compatibility guarantees, or support for complex templating—consider a maintained alternative or implement substitution inline.
Install
envsubst on PyPI
pip
pip install envsubstuv
uv add envsubstpoetry
poetry add envsubstInstalling envsubst
Before you install
Install friction is low with no runtime dependencies. However, the package is abandoned—last release was 2019-10-05 and the repository shows no commits since 2023-07-07. No active maintenance means security or compatibility issues will not be addressed.
License in practice
Licensed under MIT (permissive), so you can use, modify, and distribute the package freely with minimal restrictions.
Quickstart
import os
from envsubst import envsubst
os.environ['USER'] = 'alice'
os.environ['HOST'] = 'example.com'
result = envsubst('$USER@$HOST')
print(result) # alice@example.com
Verify before relying
- Whether the package works correctly with modern Python versions (requires_python is unspecified)
- Whether argv-based substitution ($0, $1, etc.) is fully documented or tested
- Whether nested or complex variable references beyond the documented examples are supported
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 2,505 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 144,892/month — #11,140 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: envsubst-0.1.5-py2.py3-none-any.whl
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
expandvarsExpands Unix-style variable references in…
permissive · top 5,000 on PyPI
parameter-expansion-patchedExpands POSIX and Bash shell parameter syntax…
permissive · top 15,000 on PyPI
tempenvTemporarily override environment variables…
permissive · top 15,000 on PyPI
environsenvirons parses environment variables into…
permissive · top 5,000 on PyPI
py-expression-evalParses and evaluates mathematical expressions…
permissive · top 15,000 on PyPI
pytest-envA pytest plugin that loads environment…
permissive · top 1,000 on PyPI
dynamic-yamlAdds dynamic string interpolation to YAML…
permissive · top 15,000 on PyPI
pyaml-envParses YAML configuration files and resolves…
permissive · top 15,000 on PyPI
envyamlParses YAML configuration files with…
permissive · top 5,000 on PyPI
uritemplateExpands RFC 6570 URI templates by substituting…
permissive · top 1,000 on PyPI