{"record":{"id":"2bd492f4e24147bd","repo":"PrefectHQ/fastmcp","slug":"module-name-r-has-no-attribute-name-r-2bd492","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":"fastmcp_slim/fastmcp/apps/__init__.py","lineNumber":42,"sourceCode":"    \"AppConfig\",\n    \"FastMCPApp\",\n    \"PrefabAppConfig\",\n    \"ResourceCSP\",\n    \"ResourcePermissions\",\n    \"app_config_to_meta_dict\",\n    \"resolve_ui_mime_type\",\n]\n\nif _TYPE_CHECKING:\n    from fastmcp.apps.app import FastMCPApp as FastMCPApp\n\n\ndef __getattr__(name: str) -> object:\n    if name == \"FastMCPApp\":\n        from fastmcp.apps.app import FastMCPApp\n\n        return FastMCPApp\n    raise AttributeError(f\"module {__name__!r} has no attribute {name!r}\")\n","sourceCodeStart":24,"sourceCodeEnd":43,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/apps/__init__.py#L24-L43","documentation":"This AttributeError is raised by the lazy module-level __getattr__ of fastmcp.apps when code accesses an attribute on the `fastmcp.apps` module that it does not know how to lazily import. The only lazily provided attribute is `FastMCPApp`; anything else falls through to this raise. It typically means a misspelled import or an attribute that lives in a submodule (e.g. fastmcp.apps.app) was referenced at module level.","triggerScenarios":"Accessing `fastmcp.apps.<anything-other-than-FastMCPApp>` that is not an explicitly imported name, e.g. `from fastmcp.apps import FastMCPApp misspelled as FastmcpApp/AppFastMCP`, or `import fastmcp.apps; fastmcp.apps.some_helper`.","commonSituations":"Typos in imports after upgrading versions; assuming all public symbols are re-exported from the package __init__; IDE auto-import picking the package instead of the correct submodule; code written against an older/newer layout of the apps feature.","solutions":["Use the exact exported name `FastMCPApp` (from fastmcp.apps import FastMCPApp) or import from the defining submodule, e.g. `from fastmcp.apps.app import ...`.","Check `dir(fastmcp.apps)` to see which attributes actually exist at module level.","Verify the installed fastmcp version supports the attribute (upgrade if it was added later)."],"exampleFix":"// before\nfrom fastmcp.apps import AppFastMCP\n// after\nfrom fastmcp.apps import FastMCPApp","handlingStrategy":"type-guard","validationCode":"import fastmcp.apps\nattr = \"FastMCPApp\"\nif not hasattr(fastmcp.apps, attr):\n    raise ImportError(f\"fastmcp.apps has no attribute {attr!r}; use FastMCPApp or import from fastmcp.apps.app\")","typeGuard":"def has_apps_attr(name: str) -> bool:\n    import fastmcp.apps\n    return hasattr(fastmcp.apps, name)","tryCatchPattern":"try:\n    from fastmcp.apps import FastMCPApp\nexcept AttributeError as e:\n    from fastmcp.apps.app import FastMCPApp  # or fix the name","preventionTips":["Import FastMCPApp by its exact name or from fastmcp.apps.app","Run a quick `python -c 'from fastmcp.apps import FastMCPApp'` smoke check in CI","Use IDE auto-import from the defining submodule, not the package root","Pin and review the fastmcp version when upgrading import paths"],"tags":["python","attributeerror","lazy-import"],"backgroundTag":"module-has-no-attribute","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}