我已经使用Conda安装了eccodes库,但是当我试图在ecCodes中导入它时,我得到了“无法找到ecCodes库”。
为什么我要得到这个错误,我如何解决它?我认为Python不知道在哪里可以找到库。
我用的是在这里找到的命令。那是,
conda install -c conda-forge eccodes
pip3 install --upgrade eccodes我用的是Windows机器。
发布于 2022-05-30 09:58:58
在询问了同事之后,我们通过运行代码找到了解决方案
import ecmwflibs现在电子编码已经被认可了
他发现这是因为错误消息是由~/Anaconda3/Lib/site-packages/gribapi/bindings.py中的脚本引发的。
#
# (C) Copyright 2017- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation nor
# does it submit to any jurisdiction.
#
# Authors:
# Alessandro Amici - B-Open - https://bopen.eu
# Shahram Najm - ECMWF - https://www.ecmwf.int
#
from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import pkgutil
import cffi
__version__ = "1.4.2"
LOG = logging.getLogger(__name__)
try:
import ecmwflibs as findlibs
except ImportError:
import findlibs
library_path = findlibs.find("eccodes")
if library_path is None:
raise RuntimeError("Cannot find the ecCodes library")
# default encoding for ecCodes strings
ENC = "ascii"
ffi = cffi.FFI()
CDEF = pkgutil.get_data(__name__, "grib_api.h")
CDEF += pkgutil.get_data(__name__, "eccodes.h")
ffi.cdef(CDEF.decode("utf-8").replace("\r", "\n"))
lib = ffi.dlopen(library_path)发布于 2022-05-23 15:24:55
我不会在这里惹皮普的。Conda提供了编译后的库(eccodes)和Python绑定(python-eccodes)。后者将前者列为依赖项,因此应该足以使用:
conda install -c conda-forge python-eccodeshttps://stackoverflow.com/questions/72344666
复制相似问题