无法导入cfgrib



每当我尝试导入cfgrib时,它都会给我一个运行时错误,即它无法加载ecCodes库

import cfgrib

这是完整的错误信息

RuntimeError                              Traceback (most recent call last)
/tmp/ipykernel_6224/857012844.py in <module>
----> 1 import cfgrib
~/.local/lib/python3.8/site-packages/cfgrib/__init__.py in <module>
17 
18 # cfgrib core API depends on the ECMWF ecCodes C-library only
---> 19 from .cfmessage import CfMessage
20 from .dataset import Dataset, DatasetBuildError, open_file, open_fileindex
21 from .messages import FileStream, Message
~/.local/lib/python3.8/site-packages/cfgrib/cfmessage.py in <module>
27 import numpy as np
28 
---> 29 from . import abc, messages
30 
31 LOG = logging.getLogger(__name__)
~/.local/lib/python3.8/site-packages/cfgrib/messages.py in <module>
26 
27 import attr
---> 28 import eccodes  # type: ignore
29 import numpy as np
30 
~/.local/lib/python3.8/site-packages/eccodes/__init__.py in <module>
13 import sys
14 
---> 15 from .eccodes import *
16 from .eccodes import __version__
17 from .eccodes import bindings_version
~/.local/lib/python3.8/site-packages/eccodes/eccodes.py in <module>
10 #
11 #
---> 12 from gribapi import __version__
13 from gribapi import bindings_version
14 
~/.local/lib/python3.8/site-packages/gribapi/__init__.py in <module>
11 #
12 
---> 13 from .gribapi import *  # noqa
14 from .gribapi import __version__
15 from .gribapi import bindings_version
~/.local/lib/python3.8/site-packages/gribapi/gribapi.py in <module>
2226 
2227 
-> 2228 __version__ = grib_get_api_version()
2229 
2230 
~/.local/lib/python3.8/site-packages/gribapi/gribapi.py in grib_get_api_version()
2216 
2217     if not lib:
-> 2218         raise RuntimeError("Could not load the ecCodes library!")
2219 
2220     v = lib.grib_get_api_version()
RuntimeError: Could not load the ecCodes library!

我已经通过pip 安装了cfgrib和ecCodes

cfgrib                 0.9.9.1             
eccodes                1.4.0               
eccodes-python         0.9.9

如pypi上所述(https://pypi.org/project/eccodes/)eccodes-python包依赖于eccodes系统库。根据错误消息,您没有安装它。

使用conda:安装它可能是最简单的

conda install -c conda-forge eccodes

相关内容

  • 没有找到相关文章

最新更新