skillfed

envsubst

Substitute environment variables in a string

envsubst v0.1.5 144.9K downloads/30d#11,140 on PyPI8
Permissive license MIT Abandoned released

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 envsubst

uv

uv add envsubst

poetry

poetry add envsubst

Installing 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

environment variable substitutionshell variable expansionenvsubst pythonsubstitute env vars in stringvariable interpolationdefault value fallbackshell-like variable syntax
shell-compatibilityabandoned

More Utilities packages