1

I've been trying to simply open a dataset using Python's xarray :

data = xr.open_dataset(datafile.nc)

and I've been getting the following error:

ValueError: found the following matches with the input file in xarray's IO backends: ['netcdf4', 'h5netcdf']. But their dependencies may not be installed, see: https://docs.xarray.dev/en/stable/user-guide/io.html https://docs.xarray.dev/en/stable/getting-started-guide/installing.html

I've installed xarray and its io dependencies, and checked that both netcdf4 and h5netcdf are installed on my environment; they both are. When I specify the engine:

data = xr.open_dataset(datafile.nc, engine='netcdf4')

I get the following:

ValueError: unrecognized engine netcdf4 must be one of: ['store']

Online I've seen that should netcdf4 be correctly working, I'd see it appear in the list of engines: ['netcdf4', 'store'], which I take to mean that I've not installed it correctly and that the engine isn't seen as "available". How can I add the netcdf4 engine to that list ?

mattdecoat
  • 11
  • 1

1 Answers1

0

I had similar issue. But when I installed the 'netCDF4' dependency using

    pip install netcdf4

in my environment, restarted the kernel, and opened the netcdf file using

    import xarray as xr
    ds = xr.open_dataset("path_to_the_file")
    ds

, it worked fine for me.

nibar
  • 35
  • 7