pola-rs/polars · error · FileNotFoundError

no workbook found at path

Error message

no workbook found at path {src!r}

What it means

Source-path check in read_excel/read_ods source normalization: a str/PathLike source does not exist on disk even after expanduser, and it does not look like a URL, so no workbook can be opened at that path — typically a typo or wrong relative path.

Solutions

  1. Verify the file exists at the exact path (os.path.exists / ls) and fix typos.
  2. Loosen or correct the glob pattern and check the extension matches the files on disk.
  3. If the source is remote, ensure it uses a URL scheme (http(s)://) so it is treated as a URL rather than a local path.

Example fix

// before
pl.read_excel('reports/*.xlsx')  # no matches
// after
import glob
assert glob.glob('reports/*.xlsx'), 'no workbook files present'
pl.read_excel('reports/*.xlsx')
Defensive patterns

Strategy: validation

Validate before calling

from glob import glob
from os.path import isfile
matches = glob(pattern, recursive=True)
assert matches, f'no workbook matches {pattern}'

Try / catch

try:
    df = pl.read_excel(path)
except FileNotFoundError:
    raise RuntimeError(f'check path: {path!r} does not exist') from None

Prevention

When it happens

Trigger: pl.read_excel('data/xlsx') with a typo'd path, a glob like 'data/*.xlsx' matching nothing, or the file not yet written/downloaded.

Common situations: Wrong working directory, glob pattern with wrong extension case (.XLSX vs .xlsx), remote paths that aren't URLs, files removed between existence check and read.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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

Appendix: source

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

    read_multiple_workbooks = True
    sources: list[Any] = []

    if isinstance(source, memoryview):
        source = source.tobytes()
    if not isinstance(source, Sequence) or isinstance(source, (bytes, str)):
        read_multiple_workbooks = False
        source = [source]  # type: ignore[assignment]

    for src in source:  # type: ignore[union-attr]
        if isinstance(src, (str, os.PathLike)) and not Path(src).exists():
            src = os.path.expanduser(str(src))  # noqa: PTH111
            if looks_like_url(src):
                sources.append(src)
                continue
            sources.extend(files := glob(src, recursive=True))  # noqa: PTH207
            if not files:
                msg = f"no workbook found at path {src!r}"
                raise FileNotFoundError(msg)
            read_multiple_workbooks = True
        else:
            if isinstance(src, os.PathLike):
                src = str(src)
            sources.append(src)

    return sources, read_multiple_workbooks


def _standardize_duplicates(s: str) -> str:
    """Standardize columns with '_duplicated_n' names."""
    return re.sub(r"_duplicated_(\d+)", repl=r"\1", string=s)


def _unpack_read_results(
    frames: list[pl.DataFrame] | list[dict[str, pl.DataFrame]],
    *,
    read_multiple_workbooks: bool,

View on GitHub (pinned to fe841f959e)