首页 > 解决方案 > 使用 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 install "xarray[io]" pip install "xarray[complete]" 但我得到相同的 ValueError。Python 3.8 版有什么想法吗?提前致谢!费德

标签: pythonpython-xarraymetpy

解决方案


该特定数据文件采用 netCDF-4 格式,zarr 或 scipy 都不支持。我很惊讶安装xarray[io]xarray[complete]没有修复它。尝试手动做pip install netcdf4.

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


推荐阅读