{"record":{"id":"29a8c8a7eeb95648","repo":"pola-rs/polars","slug":"module-name-r-has-no-attribute-name-r","errorCode":null,"errorMessage":"module {__name__!r} has no attribute {name!r}","messagePattern":"module (.+?) has no attribute (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/__init__.py","lineNumber":560,"sourceCode":"            )\n            return getattr(exceptions, name)\n\n        # Deprecate data type groups at top-level\n        import polars.datatypes.group as dtgroup\n\n        if name in dir(dtgroup):\n            from polars._utils.deprecation import issue_deprecation_warning\n\n            issue_deprecation_warning(\n                message=(\n                    f\"`{name}` was deprecated in version 1.0.0. Define your own data type groups or \"\n                    \"use the `polars.selectors` module for selecting columns of a certain data type.\"\n                ),\n            )\n            return getattr(dtgroup, name)\n\n        msg = f\"module {__name__!r} has no attribute {name!r}\"\n        raise AttributeError(msg)\n","sourceCodeStart":542,"sourceCodeEnd":561,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/__init__.py#L542-L561","documentation":"Raised by the module-level __getattr__ (PEP 562) of the polars package: the accessed name is not a real attribute of the top-level `polars` namespace, and it is also not one of the deprecated re-exports (exceptions accessible at top-level, or dtype groups from polars.datatypes.group) which would have returned a deprecation warning instead. Polars only resolves known deprecated aliases here; everything else raises a plain AttributeError naming the module and the missing attribute.","triggerScenarios":"Accessing any misspelled or nonexistent name on `pl`, e.g. `pl.read_cvs(...)`, `pl.data_frame(...)`, `pl.ArrowTypes`; or calling an API that was removed/moved rather than deprecated (top-level exception access moved to polars.exceptions in 1.0, dtype groups like INTEGER/TEMPORAL deprecated in 1.0).","commonSituations":"Typos picked up from autocomplete; code written for polars 0.x run under 1.x where names moved into submodules (`polars.exceptions`, `polars.selectors`, `polars.datatypes.group`); using a DataFrame/Series method as if it were a module-level function (`pl.shape`, `pl.columns`).","solutions":["Fix the typo — confirm the exact public name with `hasattr(pl, 'read_csv')` or the API reference","If it was a top-level exception (e.g. `pl.NotFoundError`), import it from `polars.exceptions` instead","If it was a dtype group (INTEGER, FLOAT, TEMPORAL, ...), replace with `polars.selectors` (e.g. `cs.integer()`) or define your own group of dtypes","If the API disappeared entirely, check the polars changelog / 1.0 upgrade guide for the new location"],"exampleFix":"// before\nimport polars as pl\ndf = pl.read_cvs(\"data.csv\")  # AttributeError: module 'polars' has no attribute 'read_cvs'\n\n// after\nimport polars as pl\ndf = pl.read_csv(\"data.csv\")\n\n// before (deprecated group path)\npl.NUMERIC_TYPES  # warns, but works\n\n// after\nimport polars.selectors as cs\ndf.select(cs.numeric())","handlingStrategy":"validation","validationCode":"import polars as pl\n\nname = \"read_csv\"  # attribute you plan to use\nif not hasattr(pl, name):\n    raise RuntimeError(f\"polars {pl.__version__} has no attribute {name!r} — check spelling/API version\")\nfn = getattr(pl, name)","typeGuard":"from typing import Any\nimport polars as pl\n\ndef has_polars_attr(name: str) -> bool:\n    \"\"\"True if the top-level polars namespace exposes `name` (PEP 562 aware).\"\"\"\n    return hasattr(pl, name)","tryCatchPattern":"try:\n    fn = getattr(pl, name)\nexcept AttributeError as e:\n    # name may be a deprecated alias that still resolves via __getattr__ with a warning,\n    # so only treat genuine absence as failure\n    raise MyAppConfigError(f\"unsupported polars API: {name}\") from e","preventionTips":["Pin the polars version and write code against that version's API docs","Resolve API handles once at startup (module constants) so typos fail fast in one place","For exception classes import from polars.exceptions; for dtype groups use polars.selectors instead of top-level names","Run a quick `hasattr(pl, '...')` guard when calling dynamically-named APIs"],"tags":["python","attribute-error","typo","api-changes","module-getattr"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}