报错信息
pygrib是一个用于读取和写入气象数据格式.grib
的Python库,在macOS上安装时遇到如下报错:
src/pygrib/_pygrib.c:1256:10: fatal error: 'grib_api.h' file not found
#include "grib_api.h"
^~~~~~~~~~~~
214 warnings and 1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pygrib
Failed to build pygrib
ERROR: Could not build wheels for pygrib, which is required to install pyproject.toml-based projects
参考方案
这个issue提出了类似的问题,平台是Ubuntu。其解决方案如下:
sudo apt install libeccodes-dev
pip install eccodes-python
解决方案
同样的思路迁移至macOS,通过homebrew安装eccodes
,并通过pip安装eccodes-python
,最终成功安装。
brew install eccodes
pip install eccodes-python
此外,注意到eccodes
包需要hdf5
包作为依赖,同某些包依赖的hdf5-mpi
形成冲突,后期需要注意。