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/definitionsPossible 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
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?
Best Answer
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 isBut in some PCs the path could be
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 )
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.