{"record":{"id":"f1d524b3fe6f790a","repo":"pola-rs/polars","slug":"a-more-recent-version-of-fastexcel-is-required-f-f1d524","errorCode":null,"errorMessage":"a more recent version of `fastexcel` is required for 'schema_sample_rows' (>= 0.9; found {original_version})","messagePattern":"a more recent version of `fastexcel` is required for 'schema_sample_rows' \\(>= 0\\.9; found (.+?)\\)","errorType":"exception","errorClass":"ModuleUpgradeRequiredError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/spreadsheet/functions.py","lineNumber":1054,"sourceCode":"    read_options: dict[str, Any],\n    schema_overrides: SchemaDict | None,\n    columns: Sequence[int] | Sequence[str] | None,\n    table_name: str | None = None,\n    drop_empty_rows: bool,\n    drop_empty_cols: bool,\n    raise_if_empty: bool,\n) -> pl.DataFrame:\n    # if we have 'schema_overrides' and a more recent version of `fastexcel`\n    # we can pass translated dtypes to the engine to refine the initial parse\n    fastexcel = import_optional(\"fastexcel\")\n    fastexcel_version = parse_version(original_version := fastexcel.__version__)\n\n    if fastexcel_version < (0, 9) and \"schema_sample_rows\" in read_options:\n        msg = f\"a more recent version of `fastexcel` is required for 'schema_sample_rows' (>= 0.9; found {original_version})\"\n        raise ModuleUpgradeRequiredError(msg)\n    if fastexcel_version < (0, 10, 2) and \"use_columns\" in read_options:\n        msg = f\"a more recent version of `fastexcel` is required for 'use_columns' (>= 0.10.2; found {original_version})\"\n        raise ModuleUpgradeRequiredError(msg)\n    if table_name and fastexcel_version < (0, 12):\n        msg = f\"a more recent version of `fastexcel` is required for 'table_name' (>= 0.12.0; found {original_version})\"\n        raise ValueError(msg)\n\n    if columns:\n        if not isinstance(columns, list):\n            columns = list(columns)  # type: ignore[assignment]\n        read_options[\"use_columns\"] = columns\n\n    schema_overrides = schema_overrides or {}\n    if read_options.get(\"schema_sample_rows\") == 0:\n        # ref: https://github.com/ToucanToco/fastexcel/issues/236\n        del read_options[\"schema_sample_rows\"]\n        read_options[\"dtypes\"] = (\n            \"string\"\n            if fastexcel_version >= (0, 12, 1)\n            else dict.fromkeys(range(16384), \"string\")\n        )","sourceCodeStart":1036,"sourceCodeEnd":1072,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/spreadsheet/functions.py#L1036-L1072","documentation":"The `schema_sample_rows` read option for the calamine engine requires fastexcel >= 0.9. If an older fastexcel is installed and that key is present in read_options, polars raises ModuleUpgradeRequiredError with the required and installed versions. This gate exists because older fastexcel lacks the schema-sampling API.","triggerScenarios":"`pl.read_excel(..., engine='calamine', read_options={'schema_sample_rows': 100})` with fastexcel < 0.9 installed.","commonSituations":"Old fastexcel in a locked environment; copied snippets using schema_sample_rows to fix type inference; CI images with stale dependencies.","solutions":["Upgrade fastexcel: pip install -U 'fastexcel>=0.9'.","Pin fastexcel>=0.9 in project dependencies.","Drop schema_sample_rows from read_options and instead pass explicit `schema_overrides`/dtypes for the affected columns."],"exampleFix":"// before\npl.read_excel('f.xlsx', engine='calamine', read_options={'schema_sample_rows': 500})\n// after\n# pip install -U 'fastexcel>=0.9'\npl.read_excel('f.xlsx', engine='calamine', read_options={'schema_sample_rows': 500})","handlingStrategy":"validation","validationCode":"from importlib.metadata import version\nfrom packaging.version import Version\nif Version(version('fastexcel')) < Version('0.9'):\n    raise RuntimeError('fastexcel>=0.9 required for schema_sample_rows')","typeGuard":null,"tryCatchPattern":"try:\n    df = pl.read_excel(path, engine='calamine', read_options={'schema_sample_rows': n})\nexcept ModuleUpgradeRequiredError:\n    df = pl.read_excel(path, engine='calamine', schema_overrides=explicit_dtypes)","preventionTips":["Pin 'fastexcel>=0.9' wherever schema_sample_rows is used","Prefer explicit schema_overrides over schema_sample_rows inference tuning","Upgrade fastexcel in CI images regularly"],"tags":["polars","fastexcel","dependency-version"],"backgroundTag":"missing-dependency","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}