1

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:\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_filestream self = cls.from_indexpath(indexpath) File "C:\Users\name\anaconda3\envs\Weather\lib\site-packages\cfgrib\messages.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:\bld\eccodes_1593015095851\work\src\grib_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 2

3

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.

1
  • After a lot of research, this solution worked for me. Just a reminder: Please make sure that you select the mentioned definitions folder and not select other definitions folders (for example other definitions folder that may exist inside other environment variables or other places where the package is installed.
    – Muser
    Jan 13, 2021 at 10:07
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.