pola-rs/polars · error · ValueError
unsupported encoding
Error message
unsupported encoding {encoding} for hf:// paths What it means
Guard in read_csv when reading from an hf:// (Hugging Face) path: only UTF-8 (the default) encoding is supported on that backend. The file is fetched over HTTP as text, so alternative encodings cannot be honored; download the file and read it locally to use another encoding.
Solutions
- Use a supported encoding for hf:// paths (e.g. 'utf8'); lossy/other encodings are not supported there.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at py-polars/src/polars/io/csv/functions.py:546 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pola-rs/polars@68506541d2 (2026-08-19).
Data as JSON: /api/errors/41a5c6a659986b56.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/io/csv/functions.py:546
lf = lf.with_row_index(name, offset)
return lf._collect_eager()
@removed_parameters(
RenamedParameter(
name="dtypes",
new_name="schema_overrides",
deprecated_in="0.20.31",
removed_in="2.0",
),
RenamedParameter(
name="row_count_name",
new_name="row_index_name",
deprecated_in="0.20.4",
removed_in="2.0",
),
RenamedParameter(
name="row_count_offset",
new_name="row_index_offset",
deprecated_in="0.20.4",
removed_in="2.0",
),
RemovedParameter(
name="rechunk",
removed_in="2.0",
hint="call `rechunk()` on the resulting Dataframe if you need contiguous memory.",
),
)
def scan_csv(
source: (
str
| Path
| IO[str]
| IO[bytes]
| bytesView on GitHub (pinned to 68506541d2)