pyaml-env
Provides yaml file parsing with environment variable resolution
What it is and what it does
pyaml-env is a thin wrapper around PyYAML that adds environment variable resolution to YAML configuration files. It lets you mark values with a custom tag (default !ENV) and substitute environment variables at parse time, keeping secrets out of version control. The library supports default values using a separator (default :), custom YAML loaders, type coercion via YAML's standard type tags, and attribute-style access through a BaseConfig wrapper.
Typical use: define a YAML config with placeholders like `password: !ENV ${DB_PASS:fallback}`, set environment variables before running your app, then call parse_config() to get a dictionary with all variables resolved. If a variable is unset and has no default, it becomes 'N/A' by default—or you can raise an error instead with raise_if_na=True.
Use it for:
- Load database credentials from environment variables in a YAML config without hardcoding secrets.
- Manage different configurations per deployment environment (dev, staging, prod) by varying environment variables.
- Provide default fallback values for optional config parameters while requiring critical ones to be set.
- Parse YAML files containing serialized Python objects using a custom loader like yaml.UnsafeLoader.
- Access nested config values as attributes (e.g., config.database.url) via BaseConfig wrapper.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses YAML configuration files and resolves environment variables marked with a custom tag, allowing secrets to be injected at runtime rather than stored in plain text.
Yes, if you use YAML for configuration and need to inject secrets via environment variables. The package is lightweight, has no security vulnerabilities, and solves a common deployment pattern. Dormant maintenance is acceptable for a stable, single-purpose tool. Install if your workflow already involves YAML and environment-based secrets; skip if you prefer .env files or other config systems.
Install
pyaml-env on PyPI
pip
pip install pyaml-envuv
uv add pyaml-envpoetry
poetry add pyaml-envInstalling pyaml-env
Before you install
Low friction: single runtime dependency (PyYAML), pure Python wheel, dormant maintenance status (last commit 2025-01-13, 578 days since release) but no active issues flagged.
License in practice
MIT license (permissive) — you can use, modify, and distribute freely with minimal restrictions.
Quickstart
pip install pyaml-env
from pyaml_env import parse_config
config = parse_config('config.yaml')
# YAML file contains: username: !ENV ${DB_USER}
# Resolves to: config['username'] = os.environ['DB_USER']
Environment variables must be set before parse_config() is called; unset variables without defaults resolve to 'N/A' by default.
Verify before relying
- Whether the package handles concurrent or multi-threaded config loading safely.
- Performance characteristics when parsing large YAML files with many environment variable substitutions.
- Compatibility with YAML anchors, aliases, and other advanced YAML features alongside environment variable tags.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — PyYAML |
| Maintenance | dormant — 578 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 203,671/month — #9,627 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyaml_env-1.2.2-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
pyyaml-env-tagAdds a custom YAML tag that lets you reference…
permissive · top 5,000 on PyPI
annotatedyamlParses and validates YAML files with support…
permissive · top 15,000 on PyPI
yaml-configReads configuration from YAML files and…
unclear · top 5,000 on PyPI
bestconfigLoads configuration from multiple file formats…
permissive · top 15,000 on PyPI
HiYaPyCoLoads and merges multiple YAML configuration…
copyleft · top 15,000 on PyPI
hierarchical-confLoads configuration from YAML files organized…
unclear · top 15,000 on PyPI
HyperPyYAMLExtends YAML syntax with Python-friendly…
permissive · top 5,000 on PyPI
simple-settingsLoads and manages application settings from…
permissive · top 15,000 on PyPI
yamlloaderProvides specialized loaders and dumpers for…
permissive · top 15,000 on PyPI
confuseConfuse is a YAML configuration library that…
permissive · top 5,000 on PyPI