{"record":{"id":"4fd785882b2d1f8b","repo":"nautechsystems/nautilus_trader","slug":"failed-to-import-config-module-config-module-name","errorCode":null,"errorMessage":"Failed to import config module {config_module_name}: {e}","messagePattern":"Failed to import config module (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/system/src/python/registration.rs","lineNumber":579,"sourceCode":"\n    let Some((config_module_name, config_class_name)) = config_path.split_once(':') else {\n        anyhow::bail!(\"config_path must be in format 'module.path:ClassName', was {config_path}\");\n    };\n\n    if config_module_name.is_empty()\n        || config_class_name.is_empty()\n        || config_class_name.contains(':')\n    {\n        anyhow::bail!(\"config_path must be in format 'module.path:ClassName', was {config_path}\");\n    }\n\n    log::debug!(\n        \"Importing config class from module: {config_module_name} class: {config_class_name}\"\n    );\n\n    let config_module = py\n        .import(config_module_name)\n        .map_err(|e| anyhow::anyhow!(\"Failed to import config module {config_module_name}: {e}\"))?;\n    let config_class = config_module\n        .getattr(config_class_name)\n        .map_err(|e| anyhow::anyhow!(\"Failed to get config class {config_class_name}: {e}\"))?;\n    let py_dict = PyDict::new(py);\n\n    for (key, value) in config {\n        let py_value = config_value_to_py(py, key, value)?;\n        py_dict.set_item(key, py_value)?;\n    }\n\n    let config_instance = match config_class.call((), Some(&py_dict)) {\n        Ok(instance) => instance,\n        Err(kwargs_err) => match config_class.call0() {\n            Ok(instance) => {\n                for (key, value) in config {\n                    let py_value = config_value_to_py(py, key, value)?;\n\n                    if let Err(setattr_err) = instance.setattr(key, py_value) {","sourceCodeStart":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/python/registration.rs#L561-L597","documentation":"Raised by `create_config_instance` when the module containing the config class (e.g. `MyActorConfig`) cannot be imported while building a config object for a Python actor or strategy from a serialized config path. The Python import failed, usually because the module does not exist or raised on import.","triggerScenarios":"Providing a `config_path` like `my_package.config:MyActorConfig` where the config module name is wrong, the module is not on sys.path, or the module raises ImportError (missing dependency) at import time.","commonSituations":"Typos in the config class path in node/backtest configs; config classes moved to different modules after refactoring; missing third-party imports inside the config module; wrong Python environment.","solutions":["Verify the full `module:Class` config path is correct and importable","Run `python -c \"from <module> import <ConfigClass>\"` in the target environment","Fix any ImportError raised inside the config module (install dependencies)","Ensure PYTHONPATH/working directory includes the package"],"exampleFix":"// before\nconfig_path = \"configs:MyActorConfig\"  # no module named 'configs'\n// after\nconfig_path = \"my_package.config:MyActorConfig\"","handlingStrategy":"validation","validationCode":"from importlib import import_module\nmod_path, _ = config_path.split(\":\")\nimport_module(mod_path)  # raises early with a clear ImportError","typeGuard":null,"tryCatchPattern":"try:\n    trader.add_actor(actor_config)\nexcept Exception as e:\n    if \"Failed to import config module\" in str(e):\n        logging.error(\"bad config module path: %s\", e)\n    raise","preventionTips":["Keep config classes importable at module top level","Verify config paths after package refactors","Install all dependencies imported by config modules"],"tags":["python","import-error","config"],"backgroundTag":"module-init-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}