Skip to content

open_dataset should fail early, before reaching guess_engine when file doesn't exist #10896

@doronbehar

Description

@doronbehar

What happened?

I ran a code in a script from long ago that uses xr.open_dataset, and I gave the script a path to a file that doesn't exist, and got this error:

ValueError: did not find a match in any of xarray's currently installed IO backends ['h5netcdf', 'scipy', 'zarr']. Consider explicitly selecting one of the installed engines via the ``engine`` parameter, or installing additional IO dependencies, see:
https://docs.xarray.dev/en/stable/getting-started-guide/installing.html
https://docs.xarray.dev/en/stable/user-guide/io.html

This made me think that maybe xarray got updated and the engine guessing algorithm got different. But apparently I was wrong, and the open_dataset file simply don't exist.

What did you expect to happen?

open_dataset to fail earlier saying there is no file in the given path, and print the path too in the error message.

Minimal Complete Verifiable Example

import xarray as xr
xr.show_versions()

xr.open_dataset("missing.h5")

Steps to reproduce

I cannot use uv to show demonstrate the issue (I use NixOS), but the issue should be simple enough for you to forgive me hopefully. It might be that installing an HDF5 backend is required, but I'm not sure.

MVCE confirmation

  • Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • Complete example — the example is self-contained, including all data and the text of any traceback.
  • Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • New issue — a search of GitHub Issues suggests this is not a duplicate.
  • Recent environment — the issue occurs with the latest version of xarray and its dependencies.

Relevant log output

ValueError: did not find a match in any of xarray's currently installed IO backends ['h5netcdf', 'scipy', 'zarr']. Consider explicitly selecting one of the installed engines via the ``engine`` parameter, or installing additional IO dependencies, see:
https://docs.xarray.dev/en/stable/getting-started-guide/installing.html
https://docs.xarray.dev/en/stable/user-guide/io.html

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS

commit: None
python: 3.13.8 (main, Oct 7 2025, 12:01:51) [GCC 14.3.0]
python-bits: 64
OS: Linux
OS-release: 6.12.56
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_IL
LOCALE: ('en_IL', 'ISO8859-1')
libhdf5: 1.14.6
libnetcdf: None

xarray: 2025.7.1
pandas: 2.3.1
numpy: 2.3.3
scipy: 1.16.2
netCDF4: None
pydap: None
h5netcdf: 1.6.4
h5py: 3.14.0
zarr: 3.1.1
cftime: None
nc_time_axis: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: 3.10.5
cartopy: None
seaborn: None
numbagg: None
fsspec: None
cupy: None
pint: 0.25.0.dev0
sparse: None
flox: None
numpy_groupies: None
setuptools: None
pip: None
conda: None
pytest: None
mypy: 1.17.1
IPython: None
sphinx: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds triageIssue that has not been reviewed by xarray team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions