{"id":10084,"library":"pyconfigurator","title":"pyconfigurator: Easy Configuration Management","description":"pyconfigurator is a Python library designed for easy and flexible configuration management, supporting INI files, environment variables, command-line arguments, and directories. It provides a simple attribute-based access API to configuration values. The current version is 0.4.19, with a release cadence that is infrequent, focusing on compatibility and minor fixes.","status":"active","version":"0.4.19","language":"en","source_language":"en","source_url":"https://github.com/charsmith/configurator","tags":["configuration","ini","environment-variables","cli-arguments","settings"],"install":[{"cmd":"pip install pyconfigurator","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The package is named 'pyconfigurator' for PyPI, but the primary module is 'configurator'.","wrong":"from pyconfigurator import Configurator","symbol":"Configurator","correct":"from configurator import Configurator"}],"quickstart":{"code":"import os\nfrom configurator import Configurator\n\n# 1. Create a dummy configuration file\nconfig_file_path = 'my_app_config.ini'\nwith open(config_file_path, 'w') as f:\n    f.write('[default]\napp_name=MyApplication\ndata_path=/var/data\nlog_level=${LOG_LEVEL_ENV:INFO}\n\n[database]\nhost=localhost\nport=5432\nuser=admin\npassword=${DB_PASSWORD_ENV:secret}')\n\n# 2. Set environment variables (optional, for demonstration)\nos.environ['LOG_LEVEL_ENV'] = 'DEBUG'\n# os.environ['DB_PASSWORD_ENV'] = 'super_secret'\n\n# 3. Initialize the Configurator\n# It loads files, then environment variables, then CLI args (if any)\nconfig = Configurator(\n    files=[config_file_path],\n    environ=os.environ, # Pass os.environ to enable env var substitution\n    # cli_args=['--database-user', 'cli_user'] # Example for CLI overrides\n)\n\n# 4. Access configuration values\nprint(f\"Application Name: {config.default.app_name}\")\nprint(f\"Data Path: {config.default.data_path}\")\nprint(f\"Log Level: {config.default.log_level}\")\nprint(f\"Database Host: {config.database.host}\")\nprint(f\"Database User: {config.database.user}\")\nprint(f\"Database Password: {config.database.password}\")\n\n# Clean up the dummy file\nos.remove(config_file_path)","lang":"python","description":"This quickstart demonstrates how to initialize `Configurator` with an INI file and environment variables, then access configuration settings using attribute-style access. It highlights environment variable substitution and default values."},"warnings":[{"fix":"Always use `from configurator import Configurator`.","message":"The package name is `pyconfigurator` but the import path for the main class is `from configurator import Configurator`. Importing `from pyconfigurator import Configurator` will result in a `ModuleNotFoundError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Understand the loading order: files -> environment variables -> command-line arguments. Structure your configuration accordingly to ensure the correct values are applied.","message":"Order of precedence for configuration sources matters. `pyconfigurator` loads files first, then applies environment variable substitutions/overrides, and finally command-line argument overrides. Be aware that later sources can overwrite values from earlier ones.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Avoid relying on `pyconfigurator`'s internal implementation details. Only interact with the documented public API of the `Configurator` object.","message":"Starting with v0.4.19, `pyconfigurator` switched its internal parser implementation away from `SafeConfigParser`. While the public API (`Configurator`) remains stable, any code that directly interacted with or relied on specific internal behaviors of `SafeConfigParser` through private attributes might encounter issues.","severity":"gotcha","affected_versions":">=0.4.19"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Change your import statement from `from pyconfigurator import Configurator` to `from configurator import Configurator`.","cause":"Attempting to import `Configurator` from `pyconfigurator` instead of `configurator`.","error":"ModuleNotFoundError: No module named 'configurator'"},{"fix":"Ensure the key exists in your configuration files, environment variables, or CLI arguments. You can check for existence using `if 'some_key' in config.section:` or provide default values during access if the library supports it (though direct attribute access usually doesn't).","cause":"Attempting to access a configuration key that does not exist in any loaded configuration source.","error":"AttributeError: 'Configurator' object has no attribute 'some_missing_key'"},{"fix":"Verify that all file paths provided to `Configurator(files=...)` are correct and the files actually exist. Use absolute paths or ensure your relative paths are correct from the execution directory.","cause":"One of the files specified in the `files` argument to `Configurator` does not exist at the given path.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'non_existent.ini'"}]}