pola-rs/polars · error · ModuleUpgradeRequiredError

a more recent version of `fastexcel` is required for…

Error message

a more recent version of `fastexcel` is required for 'use_columns' (>= 0.10.2; found {original_version})

What it means

The calamine engine delegates to the optional `fastexcel` package, and the `use_columns` read option only exists in fastexcel >= 0.10.2. When the installed fastexcel is older and `use_columns` appears in read_options, polars raises ModuleUpgradeRequiredError naming the required and found versions. It is a dependency-version gate, not a usage mistake.

Solutions

  1. Upgrade fastexcel: pip install -U 'fastexcel>=0.10.2'.
  2. Pin fastexcel>=0.10.2 in requirements/pyproject.
  3. Remove the use_columns/columns argument if upgrading is impossible, and filter columns afterwards with df.select(...).

Example fix

// before
# fastexcel 0.9.0 installed
pl.read_excel('f.xlsx', engine='calamine', columns=['a', 'b'])
// after
# pip install -U 'fastexcel>=0.10.2'
pl.read_excel('f.xlsx', engine='calamine', columns=['a', 'b'])
Defensive patterns

Strategy: validation

Validate before calling

from importlib.metadata import version
from packaging.version import Version
if Version(version('fastexcel')) < Version('0.10.2'):
    raise RuntimeError('fastexcel>=0.10.2 required for use_columns')

Try / catch

try:
    df = pl.read_excel(path, engine='calamine', columns=cols)
except ModuleUpgradeRequiredError:
    df = pl.read_excel(path, engine='calamine').select(cols)  # fallback without use_columns

Prevention

When it happens

Trigger: `pl.read_excel(..., engine='calamine', read_options={'use_columns': [...]})` (or `columns=` translated into use_columns) with fastexcel < 0.10.2 installed.

Common situations: Pinned/locked fastexcel version in requirements.txt; OS distro packages shipping old fastexcel; environments where polars was upgraded but fastexcel was not.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/4582c39f841d6670. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/src/polars/io/spreadsheet/functions.py:1051

    parser: Any,
    *,
    sheet_name: str | None,
    read_options: dict[str, Any],
    schema_overrides: SchemaDict | None,
    columns: Sequence[int] | Sequence[str] | None,
    table_name: str | None = None,
    drop_empty_rows: bool,
    drop_empty_cols: bool,
    raise_if_empty: bool,
) -> pl.DataFrame:
    # if we have 'schema_overrides' and a more recent version of `fastexcel`
    # we can pass translated dtypes to the engine to refine the initial parse
    fastexcel = import_optional("fastexcel")
    fastexcel_version = parse_version(original_version := fastexcel.__version__)

    if fastexcel_version < (0, 9) and "schema_sample_rows" in read_options:
        msg = f"a more recent version of `fastexcel` is required for 'schema_sample_rows' (>= 0.9; found {original_version})"
        raise ModuleUpgradeRequiredError(msg)
    if fastexcel_version < (0, 10, 2) and "use_columns" in read_options:
        msg = f"a more recent version of `fastexcel` is required for 'use_columns' (>= 0.10.2; found {original_version})"
        raise ModuleUpgradeRequiredError(msg)
    if table_name and fastexcel_version < (0, 12):
        msg = f"a more recent version of `fastexcel` is required for 'table_name' (>= 0.12.0; found {original_version})"
        raise ValueError(msg)

    if columns:
        if not isinstance(columns, list):
            columns = list(columns)  # type: ignore[assignment]
        read_options["use_columns"] = columns

    schema_overrides = schema_overrides or {}
    if read_options.get("schema_sample_rows") == 0:
        # ref: https://github.com/ToucanToco/fastexcel/issues/236
        del read_options["schema_sample_rows"]
        read_options["dtypes"] = (
            "string"

View on GitHub (pinned to fe841f959e)