{"record":{"id":"4140ce13c698b1a4","repo":"BerriAI/litellm","slug":"module-name-r-has-no-attribute-name-r-4140ce","errorCode":null,"errorMessage":"module {__name__!r} has no attribute {name!r}","messagePattern":"module (.+?) has no attribute (.+?)","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"litellm/images/main.py","lineNumber":1033,"sourceCode":"            model=model,\n            custom_llm_provider=custom_llm_provider,\n            original_exception=e,\n            completion_kwargs=local_vars,\n            extra_kwargs=kwargs,\n        )\n\n\ndef __getattr__(name: str) -> Any:\n    \"\"\"Lazy import handler for images.main module\"\"\"\n    if name == \"ImageEditRequestUtils\":\n        # Lazy load ImageEditRequestUtils to avoid heavy import from images.utils at module load time\n        from .utils import ImageEditRequestUtils as _ImageEditRequestUtils\n\n        # Cache it in the module's __dict__ for subsequent accesses\n        module: Final = importlib.import_module(__name__)\n        module.__dict__[\"ImageEditRequestUtils\"] = _ImageEditRequestUtils\n        return _ImageEditRequestUtils\n    raise AttributeError(f\"module {__name__!r} has no attribute {name!r}\")\n","sourceCodeStart":1015,"sourceCodeEnd":1034,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/images/main.py#L1015-L1034","documentation":"litellm.images.main defines a module-level __getattr__ that lazily imports only ImageEditRequestUtils; any other unknown attribute access raises AttributeError('module ... has no attribute ...') (litellm/images/main.py:1033). This is standard Python behavior for missing module attributes surfaced through the lazy-import hook.","triggerScenarios":"getattr(litellm.images.main, 'SomeName'), from litellm.images.main import SomeName where SomeName doesn't exist; misspelling an export; relying on an attribute removed or renamed between litellm versions.","commonSituations":"Code written against a different litellm version importing a symbol that moved; IDE autocomplete suggesting a stale name; dynamic inspection tooling probing module attributes.","solutions":["Check dir(litellm.images.main) for the actual exported names and correct the import","Import the symbol from its canonical module (e.g. litellm.images.utils for ImageEditRequestUtils)","Upgrade/downgrade litellm to the version whose API surface your code targets","For dynamic access, guard with hasattr() before getattr()"],"exampleFix":"# before\nfrom litellm.images.main import ImageGenerationUtils  # AttributeError\n\n# after\nfrom litellm.images.utils import ImageEditRequestUtils","handlingStrategy":"type-guard","validationCode":"import litellm.images.main as images_main\n\nAVAILABLE = set(dir(images_main))\nassert \"ImageEditRequestUtils\" in AVAILABLE","typeGuard":"def module_has(module, name: str) -> bool:\n    try:\n        getattr(module, name)\n        return True\n    except AttributeError:\n        return False","tryCatchPattern":"try:\n    from litellm.images.main import ImageEditRequestUtils\nexcept AttributeError as e:\n    from litellm.images.utils import ImageEditRequestUtils  # canonical location","preventionTips":["Import from canonical modules rather than internal routing modules","Guard dynamic getattr with hasattr","Track litellm release notes for moved/renamed symbols"],"tags":["import","attribute-error","lazy-import","python"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}