netcdf 文件的 xarray 中的 IO 后端错误

IO backend error in the xarray for netcdf file

我正在尝试使用 xarray 打开 .netcdf 文件,但显示此错误。我无法解决此错误,而且我找不到解决此错误的解决方案。我尝试过不同版本的 Anaconda 和 Ubuntu,但问题仍然存在。

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

我遇到了同样的问题。然后我通过以下方式安装了 netCDF4:

pip install netCDF4 

xarray 成功了。当心依赖性!!

我也遇到了同样的问题。这件事情,需要安装IO依赖。 根据他们的网站 here 你需要安装所有 IO 相关的包:

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

根据您的错误消息,您似乎只缺少 scipy 依赖项。

我建议在您的 terminal/command 行或 Jupyter 中使用 conda install 安装(如果您使用 IDE): conda install scipy

如果您使用的是基础环境以外的 Python 环境,请通过在终端中导航或通过 运行 上的内核确保您正在安装到用于项目的环境Jupyter 中的那个环境。

如果您使用的是 Jupyter,您可能需要重新启动内核才能使更改生效。

感谢 Wilson 和 Water77。在我的例子中,我在我的根环境中安装了所有的包,但我意识到我应该创建一个不同的 python 环境来安装所有的包并且它对我有用。

我知道安装依赖项是第一步。 但是,我想指出,由于 损坏的 netCDF 文件 !

,我 运行 陷入了这个问题

conda install scipy

解决问题