5

I am trying to open a .netcdf file using xarray and it is showing this error. I am unable to resolve this error and I have found no such solution to resolve this error. I have tried with different versions of Anaconda and Ubuntu but the problem persists.

ValueError: did not find a match in any of xarray's currently installed IO backends ['scipy']. Consider explicitly selecting one of the installed backends via the engine parameter to xarray.open_dataset(), or installing additional IO dependencies: http://xarray.pydata.org/en/stable/getting-started-guide/installing.html http://xarray.pydata.org/en/stable/user-guide/io.html

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
saurabh rathore
  • 53
  • 1
  • 1
  • 3

5 Answers5

5

I had the same issue. I then installed netCDF4 via:

pip install netCDF4 

and xarray worked. Beware of dependencies!!

Bart
  • 9,825
  • 5
  • 47
  • 73
SAEERON
  • 336
  • 1
  • 6
2

I had the same problem as well. In this matter, you need to install IO dependencies. Based on their web site here you need to install all IO related packages:

io = netCDF4, h5netcdf, scipy, pydap, zarr, fsspec, cftime, rasterio, cfgrib, pooch 

conda install -c anaconda netcdf4 h5netcdf scipy pydap zarr fsspec cftime rasterio cfgrib pooch
water77
  • 103
  • 9
  • 5
    better would be to use `xarray`'s list of i/o packages to install: eg: `pip install "xarray[io]"` – 7yl4r Oct 15 '21 at 17:03
1

This error message can also be triggered when simply having an error in the path to the file to be opened. For example this results in the same/similar error (even with the netcdf backend installed):

import xarray as xr
xr.open_dataset("this_file_does_not_exist.nc")

So before (re)installing any packages, make sure to check whether the input to xr.open_dataset() is correct.

  • Thanks! This comment helped me. My filename was stored inside of a list, rather than just being a string, and it gave me an error about backends when I tried to load it. If you're using glob to locate a file, don't make this same mistake. – Michael Erb Apr 26 '23 at 16:58
0

Based on your error message, it looks like you are only missing the scipy dependency.

I would recommend installing using conda install in either your terminal/command line or in Jupyter (if you use that IDE): conda install scipy

If you are using a Python environment other than your base environment, ensure you are installing to the environment are using for the project by navigating there in terminal (e.g., conda activate MYENV), or by running that environment kernel in Jupyter.

You may need to restart the kernel if you are using Jupyter for the change to take effect.

0

conda install scipy

solves the problem

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 02 '22 at 02:44