【问题标题】:How do I resolve this AttributeError when using eccodes/grib?使用 eccodes/grib 时如何解决此 AttributeError?
【发布时间】:2020-11-12 14:55:54
【问题描述】:

我在 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')

我已经下载了所有似乎需要的东西,包括 eccodes、pyeccodes、cfgrib。我该如何解决这个问题?

【问题讨论】:

  • 为此,您需要 cfgrib、eccodes 和 python-eccodes,而不是 pyeccodes IIRC。

标签: python grib cfgrib eccodes


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    我认为问题在于我在 cfgrib 之前安装了metpy。似乎metpy设置了一些与cfgrib冲突的包,因为经过多次试验和错误,我创建了一个新的虚拟python环境并通过以下方式解决了问题:

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

    在环境变量中设置 eccodes 定义路径...

    变量名称:ECCODES_DEFINITION_PATH 变量值:C:\Users\path\to\eccodes\definitions

    我想这对于您的 MacOS 来说应该类似于 ECCODES_DEFINITION_PATH=./path/to/eccodes/definitions。

    【讨论】:

      猜你喜欢
      • 2021-11-21
      • 1970-01-01
      • 2020-11-06
      • 1970-01-01
      • 2011-09-13
      • 2021-08-22
      • 2021-05-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多