headroomlabs-ai/headroom · error · AttributeError
module {__name__!r} has no attribute {name!r}
Error message
module {__name__!r} has no attribute {name!r} What it means
headroom.memory implements lazy submodule loading via a module-level __getattr__: names like DirectMem0Adapter and DirectMem0Config are imported from headroom.memory.backends.direct_mem0 only on first access. This AttributeError is the fallback branch meaning the requested name is neither eagerly exported nor one of the known lazily-imported optional symbols — i.e. a typo or a symbol that lives elsewhere.
Source
Thrown at headroom/memory/__init__.py:190
_Mem0Config = Mem0Config
return _Mem0Config
if name == "DirectMem0Adapter":
if _DirectMem0Adapter is None:
from headroom.memory.backends.direct_mem0 import DirectMem0Adapter
_DirectMem0Adapter = DirectMem0Adapter
return _DirectMem0Adapter
if name == "DirectMem0Config":
if _DirectMem0Config is None:
from headroom.memory.backends.direct_mem0 import Mem0Config as DirectMem0Config
_DirectMem0Config = DirectMem0Config
return _DirectMem0Config
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
__all__ = [
# =========================================================================
# Simple API (recommended for most users)
# =========================================================================
"Memory", # Zero-config memory class
"MemoryResult", # Search result dataclass
# =========================================================================
# LLM Wrapper API
# =========================================================================
"with_memory",
"MemoryWrapper",
# Tool-based wrapper
"with_memory_tools",
"MemoryToolsWrapper",
# =========================================================================
# Core orchestratorView on GitHub (pinned to 322425c43b)
Solutions
- Check the module's __all__ (printed right below the raise) and use one of those names.
- Import from the correct submodule: from headroom.memory.backends.direct_mem0 import Mem0Config, or from headroom.memory.adapters... for adapters.
- Verify spelling and casing exactly against the headroom version you have installed.
- If upgrading headroom changed the API, read the changelog for renamed lazy symbols.
Example fix
# before from headroom.memory import Mem0Config # AttributeError: module 'headroom.memory' has no attribute 'Mem0Config' # after from headroom.memory import DirectMem0Config # the registered lazy alias
Defensive patterns
Strategy: type-guard
Validate before calling
import headroom.memory as hm
wanted = "DirectMem0Config"
if not (hasattr(hm, wanted) or wanted in getattr(hm, "__all__", ())):
raise SystemExit(f"{wanted} is not exported by headroom.memory; check __all__") Type guard
import headroom.memory as hm
def memory_exports(name: str) -> bool:
"""True if name is importable from headroom.memory (eager or lazy)."""
return name in hm.__all__ or hasattr(hm, name) Try / catch
try:
from headroom.memory import DirectMem0Config
except AttributeError as e:
raise SystemExit(
f"{e}; import from the defining submodule instead: "
"from headroom.memory.backends.direct_mem0 import Mem0Config"
) from None Prevention
- Program against __all__, not against names you remember from source browsing.
- For deep/optional classes, import from the submodule that defines them.
- After upgrading headroom, grep its __all__ lists for renames before assuming removal.
When it happens
Trigger: from headroom.memory import Something with a misspelled name (e.g. Mem0Config instead of DirectMem0Config), or accessing an attribute that only exists on a submodule (headroom.memory.backends...) directly on the package, or referencing an optional adapter class whose lazy branch was renamed in a newer headroom version.
Common situations: IDE autocomplete suggesting submodule names; version upgrades that moved/renamed lazily-loaded backends; code written against headroom.memory.backends.* but importing from headroom.memory; `from headroom.memory import *` users hitting names not in __all__.
Related errors
- module {__name__!r} has no attribute {name!r}
- module {__name__!r} has no attribute {name!r}
- any-llm-sdk is required for AnyLLMBackend. Install with: pip
- litellm is required for LiteLLMBackend. Install with: pip in
- Magika is required for ML-based content detection. Install w
AI-assisted analysis of headroomlabs-ai/headroom@322425c43b (2026-08-15).
Data as JSON: /api/errors/aca59e7f653f92ce.
Report an issue: GitHub.