gpt4 book ai didi

python - 在 Spyder 中打开 .GRIB 文件时出现 ECCODES 错误

转载 作者:行者123 更新时间:2023-12-04 04:01:57 25 4
gpt4 key购买 nike

我已经为我将要工作的环境访问了 Anaconda Prompt。

在那里,我将目录更改为我将使用的 grib 文件所在的位置,为了安装 cfgrib,我使用了以下命令:

conda install -c conda-forge cfgrib

由于 Python 模块依赖于 ECMWF ecCodes 二进制库,因此在同一个 Anaconda Prompt 中,我运行了以下命令:

conda install -c conda-forge eccodes

然后,在 Spyder 中打开文件,并尝试运行这个简单的脚本:

import xarray as xr

ds = xr.open_dataset('download.grib', engine='cfgrib')
ds

但是出现如下错误:

Can't read index file 'C:\Users\name\Desktop\data\download.grib.90c91.idx'Traceback (most recent call last):File "C:\Users\name\anaconda3\envs\Weather\lib\site-packages\cfgrib\messages.py", line 351, in from_indexpath_or_filestreamself = cls.from_indexpath(indexpath)File "C:\Users\name\anaconda3\envs\Weather\lib\site-packages\cfgrib\messages.py", line 323, in from_indexpathreturn pickle.load(file)EOFError: Ran out of input

然后,

An error ocurred while starting the kernelECCODES ERROR : Unable to find boot.def. Context path=D:/bld/eccodes_1593015095851/_h_env/Library/share/eccodes/definitions

Possible causes:‑ The software is not correctly installed‑ The environment variable ECCODES_DEFINITION_PATH is defined but incorrect ecCodes assertion failed: `0' in D:\bld\eccodes_1593015095851\work\src\grib_context.c:226

Error starting the kernel

我在这里错过了什么?


编辑 1

如果我使用 Visual Studio Code,也会出现此问题。

在终端中,如果我在存储 GRIB 文件的目录中,并激活我正在使用的环境:

conda activate Weather

然后:

& C:/Users/name/anaconda3/envs/Weather/python.exe c:/Users/name/Desktop/data/3_climate/2mtemp_open.py

它给出了与上面相同的错误。

最佳答案

如错误所述,未设置 ECCODES_DEFINITION_PATH

由于我在Windows 10上使用Anaconda,路径如下

C:/Users/[USER]/Anaconda3/envs/envgeo/Library/share/eccodes/definitions

为了设置环境变量,可以简单地运行

setx ECCODES_DEFINITION_PATH "[ECCODES definition path/directory]"

这应该可以解决问题。

然而,一个新的可能会出现。由于 .grib 文件可能需要很多时间才能运行,请考虑使用 NetCDF 格式的数据。

关于python - 在 Spyder 中打开 .GRIB 文件时出现 ECCODES 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62939533/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com