使用 MetPy 和 xarray 的 ValueError

问题描述

我正在尝试使用 https://unidata.github.io/MetPy/latest/examples/Four_Panel_Map.html#sphx-glr-download-examples-four-panel-map-py 中的一些脚本来制作天气图,但我在运行此脚本时发现了这个问题:

Traceback (most recent call last):
  File "C:/Users/fedec/PycharmProjects/met2/four-panel.py",line 46,in <module>
    ds = xr.open_dataset(get_test_data('gfs_output.nc',False))
  File "C:\Users\fedec\PycharmProjects\met2\venv\lib\site-packages\xarray\backends\api.py",line 480,in open_dataset
    engine = plugins.guess_engine(filename_or_obj)
  File "C:\Users\fedec\PycharmProjects\met2\venv\lib\site-packages\xarray\backends\plugins.py",line 111,in guess_engine
    raise ValueError(
ValueError: did not find a match in any of xarray's currently installed IO backends ['scipy','zarr']. 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

Process finished with exit code 1

我认为我在使用 xarray 时遇到了一些问题,所以我尝试升级我的 xarray: pip 安装“xarray[io]” pip 安装“xarray[完整]” 但我得到了相同的 ValueError。 Python 3.8 版 有什么想法吗?提前致谢! 费德

解决方法

那个特定的数据文件是 netCDF-4 格式的,zarr 或 scipy 都不支持。我很惊讶安装 xarray[io]xarray[complete] 并没有修复它。尝试手动执行 pip install netcdf4

(如果这不起作用,请在此处评论并使用新错误更新上面的回溯。)