使用eccodes/grib时如何解决此AttributeError



我在macOS上使用cfgrib,当我试图使用将grib文件转换为xarray时,我收到了以下错误:

AttributeError: module 'pyeccodes.compat' has no attribute 'codes_grib_multi_support_off'

这是我迄今为止的代码:

import xarray as xr
import matplotlib.pyplot as plt
import matplotlib.style as sty
sty.use('classic')
import numpy as np
import cartopy.crs as ccrs
d7 = xr.open_dataset('2007_BLH.grib', engine='cfgrib')

我已经下载了所有需要的东西,包括eccode、pyeccode、cfgrib。如何解决此问题?

使用包管理器安装ecCodes二进制文件,请参阅:https://github.com/ecmwf/cfgrib#binary-依赖关系。

我在使用Anaconda3的Windows 10机器上遇到了同样的错误,但希望我的解决方案会有所帮助。

我想问题是我在cfgrib之前安装了metpy。看起来metpy设置了一些与cfgrib冲突的包,因为经过多次尝试和错误,我创建了一个新的虚拟python环境,并通过以下操作解决了问题:

conda install-n new_env cfgrib//将包安装到我的新虚拟环境中

在环境变量中设置密码定义路径。。。

变量名:ECCODES_DEFINITION _PATH变量值:C:\Users\path\to\eccodes\definitions

我想这看起来像ECCODES_DEFINITION _PATH=/路径/到/eccodes/definitions。

相关内容

最新更新