{"record":{"id":"09f440a6b6bafbef","repo":"crewAIInc/crewAI","slug":"module-crewai-has-no-attribute-name-r","errorCode":null,"errorMessage":"module 'crewai' has no attribute {name!r}","messagePattern":"module 'crewai' has no attribute (.+?)","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"lib/crewai/src/crewai/__init__.py","lineNumber":66,"sourceCode":"\n_suppress_pydantic_deprecation_warnings()\n\n__version__ = \"1.15.16\"\n\n_LAZY_IMPORTS: dict[str, tuple[str, str]] = {\n    \"Memory\": (\"crewai.memory.unified_memory\", \"Memory\"),\n}\n\n\ndef __getattr__(name: str) -> Any:\n    \"\"\"Lazily import heavy modules (e.g. Memory → lancedb) on first access.\"\"\"\n    if name in _LAZY_IMPORTS:\n        module_path, attr = _LAZY_IMPORTS[name]\n        mod = importlib.import_module(module_path)\n        val = getattr(mod, attr)\n        globals()[name] = val\n        return val\n    raise AttributeError(f\"module 'crewai' has no attribute {name!r}\")\n\n\ntry:\n    from crewai.agents.agent_builder.base_agent import BaseAgent as _BaseAgent\n    from crewai.agents.agent_builder.base_agent_executor import (\n        BaseAgentExecutor as _BaseAgentExecutor,\n    )\n    from crewai.agents.tools_handler import ToolsHandler as _ToolsHandler\n    from crewai.experimental.agent_executor import AgentExecutor as _AgentExecutor\n    from crewai.hooks.llm_hooks import LLMCallHookContext as _LLMCallHookContext\n    from crewai.tools.tool_types import ToolResult as _ToolResult\n    from crewai.utilities.prompts import (\n        StandardPromptResult as _StandardPromptResult,\n        SystemPromptResult as _SystemPromptResult,\n    )\n\n    _base_namespace: dict[str, type] = {\n        \"Agent\": Agent,","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai/src/crewai/__init__.py#L48-L84","documentation":"crewai's package __init__ implements PEP 562 lazy importing via __getattr__: known heavy names (e.g. Memory) import on first access, and anything not in the _LAZY_IMPORTS mapping raises AttributeError('module crewai has no attribute ...'). This most often surfaces with 'from crewai import X' where X was renamed, moved, or is genuinely not exported.","triggerScenarios":"Accessing an attribute not listed in _LAZY_IMPORTS and not imported at package top level - e.g. crewai.SomeClass, or 'from crewai import Agent' variants where the name is misspelled/removed; also copy/pasted code targeting a different crewai version.","commonSituations":"Upgrading crewai and hitting renamed/removed public names; IDE autocompleting a private symbol; tutorials referencing exports that only exist in newer/older versions; old memory of names like crewai.Utilities.","solutions":["Check the export list: python -c 'import crewai; print(crewai.__all__)' and import the correct public name.","If the class exists but moved, import from its submodule directly (e.g. from crewai.memory.unified_memory import Memory).","Pin/align crewai versions between development and production; consult the changelog for renames.","Fix typos in the attribute name."],"exampleFix":"# before\nfrom crewai import MemoryConfig  # AttributeError if not exported\n\n# after\nfrom crewai.memory.config import MemoryConfig  # import from the owning submodule","handlingStrategy":"type-guard","validationCode":"import crewai\n\nname = 'Memory'\nif name not in getattr(crewai, '_LAZY_IMPORTS', {}) and not hasattr(crewai, name):\n    raise AttributeError(f'crewai does not export {name!r} - check version/renames')","typeGuard":"import crewai\n\ndef exports(name: str) -> bool:\n    return hasattr(crewai, name) or name in getattr(crewai, '_LAZY_IMPORTS', {})","tryCatchPattern":"try:\n    from crewai import Memory\nexcept AttributeError as e:\n    # fall back to the canonical submodule path\n    from crewai.memory.unified_memory import Memory","preventionTips":["Pin the crewai version and read its __init__/_LAZY_IMPORTS for the public surface.","Prefer importing from owning submodules for less-common classes.","Run import smoke tests after upgrades in CI."],"tags":["import","attribute-error","versioning","lazy-import"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}