Install & Compatibility
Where this runs
tested against v2.2.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.218s · 20.4MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.8s · import 0.210s · 22MB
19MB installed
● package 19MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Configuration
✓ from confuse import Configuration
✗ from confuse import Configuration
This quickstart demonstrates how to initialize `confuse.Configuration`, load default settings from a `config_default.yaml` file, and apply overrides from environment variables. It also shows how to retrieve values with type validation using the `.get()` method.
import confuse
import os
# Simulate a config_default.yaml in your package for defaults
# For this example, we'll create a dummy file for demonstration
# In a real app, this would be alongside your module, e.g., myapp/config_default.yaml
with open('config_default.yaml', 'w') as f:
f.write('greeting: Hello
name: World
port: 8080
enabled: true')
class MyAppConfig(confuse.Configuration):
# Override config_dir to point to current directory for this example
# In a real app, this would typically resolve OS-specific paths.
def config_dir(self):
return os.getcwd()
# Initialize configuration for 'MyGreatApp'
# __name__ is used by Confuse to find in-package config_default.yaml
config = MyAppConfig('MyGreatApp', __name__)
# Load environment variables with default prefix 'MYGREATAPP_'
# For example, export MYGREATAPP_NAME="Confuse User"
# and MYGREATAPP_PORT=9000
config.set_env()
# Get values, validating types
greeting = config['greeting'].get(str)
name = config['name'].get(str)
port = config['port'].get(int)
is_enabled = config['enabled'].get(bool)
print(f"Greeting: {greeting}")
print(f"Name: {name}")
print(f"Port: {port}")
print(f"Enabled: {is_enabled}")
# Test an environment variable override
os.environ['MYGREATAPP_NAME'] = 'AI Assistant'
os.environ['MYGREATAPP_PORT'] = '9001'
# Reload env vars to pick up changes
config.set_env()
print(f"\nAfter env var override:")
print(f"Name: {config['name'].get(str)}")
print(f"Port: {config['port'].get(int)}")
# Clean up dummy file
os.remove('config_default.yaml')
Upgrade
Version history
2.2.1latest on PyPI · released Jul 19, 2026
Audit
Dependencies
pythonrequiredRequires Python 3.10 or higher.
PyYAMLrequiredImplicitly used for YAML parsing, though not a direct pip dependency.