TransWikia.com

ECCODES ERROR when opening .GRIB file in Spyder/Visual Studio Code

Geographic Information Systems Asked on November 1, 2021

I have accessed Anaconda Prompt for the environment that I will be working.

Once there, I have changed the directory to the place where I have the grib files that I will be working with, in order to install cfgrib, I have used the following command:

conda install -c conda-forge cfgrib

As the Python module depends on ECMWF ecCodes binary library, in the same Anaconda Prompt, I ran the following command:

conda install -c conda-forge eccodes

Then, opened the file in Spyder, and tried to run this simple script:

import xarray as xr

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

But got the following error:

Can’t read index file ‘C:UsersnameDesktopdatadownload.grib.90c91.idx’
Traceback (most recent call last):
File "C:Usersnameanaconda3envsWeatherlibsite-packagescfgribmessages.py", line 351, in from_indexpath_or_filestream
self = cls.from_indexpath(indexpath)
File "C:Usersnameanaconda3envsWeatherlibsite-packagescfgribmessages.py", line 323, in from_indexpath
return pickle.load(file)
EOFError: Ran out of input

Then,

An error ocurred while starting the kernel
ECCODES 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:bldeccodes_1593015095851worksrcgrib_context.c:226

Error starting the kernel

The problem also happens if I use Visual Studio Code.

In the terminal, if I am inside the directory that the GRIB files are stored, and I activate the environment that I am working with:

conda activate Weather

And then:

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

It gives the same error as above.

What am I missing here?

2 Answers

I also encountered this problem when I launched Spyder individually. But this problem fixed when I launched Spyder from the Anaconda environment.

Answered by Ellen Lu on November 1, 2021

I solved that problem just creating an environment variable called ECCODES_DEFINITION_PATH. You have to find the path to "definition" folder. In my PC, That path is

C:/Users/Geanderson.GEANDERSON-MICH/anaconda3/Library/share/eccodes/definitions

But in some PCs the path could be

C:/Users/Robson/Anaconda3/envs/envgeo/Library/share/eccodes/definitions

So, you have to find the path in your PC now. After that, you need to create a path. One way to do it is typing in your Command Prompt ( as admin )

setx ECCODES_DEFINITION_PATH "type here the path to definition folder"

Learning about creating environment variable: https://devcontent.com.br/artigos/windows/o-que-sao-como-alterar-criar-excluir-variaveis-de-ambiente

Then press enter to close the Command Prompt.

Answered by Geanderson Michel on November 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP