The simplest way to manage environment variables in Python.
Load .env, .json, and .yaml config files in one line of code.
Access your variables with clean dot notation — no more os.getenv() boilerplate.
Managing environment variables in Python shouldn't be painful. Most solutions either force you into a single file format, require verbose syntax, or lack support for nested configurations.
EasyWorkEnv solves this by providing:
- Multi-format support —
.env,.json, and.yamlout of the box - Dot notation access —
config.DATABASE.HOSTinstead ofconfig["DATABASE"]["HOST"] - Nested configuration — structure your settings with unlimited depth
- Zero config — just point to your file, it works
- Lightweight — only one dependency (
PyYAML) - Python 3.8+ compatible
pip install easyworkenvfrom EasyWorkEnv import Config
config = Config(".env")
# Access your variables directly as attributes
print(config.API_KEY)
print(config.DATABASE_URL)That's it. One import, one line of setup.
# .env
APP_NAME=MyApp
SECRET_KEY=super-secret-value
DEBUG=true
DATABASE_URL=postgresql://localhost:5432/mydbfrom EasyWorkEnv import Config
config = Config(".env")
print(config.APP_NAME) # "MyApp"
print(config.SECRET_KEY) # "super-secret-value"
print(config.DATABASE_URL) # "postgresql://localhost:5432/mydb"{
"APP_NAME": "MyApp",
"DATABASE": {
"HOST": "localhost",
"PORT": 5432,
"NAME": "mydb"
},
"API_KEY": "sk-abc123"
}from EasyWorkEnv import Config
config = Config("config.json")
print(config.APP_NAME) # "MyApp"
print(config.DATABASE.HOST) # "localhost"
print(config.DATABASE.PORT) # 5432
print(config.API_KEY) # "sk-abc123"# config.yaml
APP_NAME: MyApp
DATABASE:
HOST: localhost
PORT: 5432
NAME: mydb
REDIS:
URL: redis://localhost:6379from EasyWorkEnv import Config
config = Config("config.yaml")
print(config.APP_NAME) # "MyApp"
print(config.DATABASE.HOST) # "localhost"
print(config.REDIS.URL) # "redis://localhost:6379"| Format | Extension | Nested Config | Comments |
|---|---|---|---|
| dotenv | .env |
No | Yes |
| JSON | .json |
Yes | No |
| YAML | .yaml |
Yes | Yes |
Contributions are welcome! If you'd like to help improve EasyWorkEnv:
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -m "Add my feature") - Push to the branch (
git push origin feature/my-feature) - Open a Pull Request
This project is licensed under the GNU General Public License v3.0 — see the LICENSE file for details.
Made by Hugo Galley