Greetings,
I hope this message can reach the right person. I'm trying to run the notebook for seasonal forecast anomalies
https://ecmwf-projects.github.io/copernicus-training-c3s/sf-anomalies.html
Unfortunately, I get the below error. I've been trying to solve this for a long time. I had this bug on mac and recently on a new windows computer. Have you experienced this before? if so, could you please help me to solve this problem?
Thank you very much,
Carlo

---------------

ds = xr.open_dataset(f'{DATADIR}/ecmwf_seas5_1993-2016_05_hindcast_monthly_tp.grib', engine='cfgrib')
ds


  • No labels

9 Comments

  1. Hi Carlo!

    is it ecCodes installed in your system? have the notebook cells installing and importing the relevant modules run properly on your notebook?

    Have a look at the system dependencies section here: https://pypi.org/project/cfgrib/0.8.4.5/

    Regards!

    Edu

    1. Thank you Edu,
      Yes, I have ecCodes installed.

      python -m cfgrib selfcheck
      Found: ecCodes v2.24.2.
      Your system is ready.

      I'm not sure about the dependencies, I'm on a windows machine and the instructions are for linux and mac only. Also, this link is broken https://software.ecmwf.int/wiki/display/ECC/ecCodes+installation
      Any ideas?
      Thank you!
      Carlo

      1. I'm sorry I can't help you further.

        If no other users can provide helpful feedback... have you tried contacting User Support? http://support.ecmwf.int

    2. Do you get the same error also when you run the script from the terminal? Try checking if Jupyter is using the right kernel (the one with cfgrib installed). 

      Also, have you tried installing cfgrib both with conda and pip? 

  2. thank you for the clues

    I'm using a base kernel, I wasn't able to find the kernel cfgrid installs 

  3. I ran it as a py file and I got the same error

    1. So, if you open a python terminal and you type import cfgrib you don't get any errors? 

  4. same thing. But it seems eccodes is the problem



    {
        "name": "RuntimeError",
        "message": "ecCodes library not found using ['eccodes', 'libeccodes.so', 'libeccodes']",
        "stack": "---------------------------------------------------------------------------
    ModuleNotFoundError                       Traceback (most recent call last)
    File c:\\Users\\cmont\\anaconda3\\Lib\\site-packages\\gribapi\\bindings.py:29
         28 try:
    ---> 29     from ._bindings import ffi, lib
         30 except ModuleNotFoundError:

    ModuleNotFoundError: No module named 'gribapi._bindings'

    During handling of the above exception, another exception occurred:

    RuntimeError                              Traceback (most recent call last)
    Cell In[2], line 15
         13 from dateutil.relativedelta import relativedelta
         14 import calendar
    ---> 15 import cfgrib
         16 # Libraries for plotting and geospatial data visualisation
         17 from matplotlib import pyplot as plt

    File c:\\Users\\cmont\\anaconda3\\Lib\\site-packages\\cfgrib\\__init__.py:20
         18 # cfgrib core API depends on the ECMWF ecCodes C-library only
         19 from .abc import Field, Fieldset, Index, MappingFieldset
    ---> 20 from .cfmessage import COMPUTED_KEYS
         21 from .dataset import (
         22     Dataset,
         23     DatasetBuildError,
       (...)
         27     open_from_index,
         28 )
         29 from .messages import FieldsetIndex, FileStream, Message

    File c:\\Users\\cmont\\anaconda3\\Lib\\site-packages\\cfgrib\\cfmessage.py:29
         26 import attr
         27 import numpy as np
    ---> 29 from . import abc, messages
         31 LOG = logging.getLogger(__name__)
         33 # taken from eccodes stepUnits.table

    File c:\\Users\\cmont\\anaconda3\\Lib\\site-packages\\cfgrib\\messages.py:28
         25 import typing as T
         27 import attr
    ---> 28 import eccodes  # type: ignore
         29 import numpy as np
         31 from . import abc

    File c:\\Users\\cmont\\anaconda3\\Lib\\site-packages\\eccodes\\__init__.py:15
         12 from __future__ import absolute_import
         13 import sys
    ---> 15 from .eccodes import *
         16 from .eccodes import __version__
         17 from .eccodes import bindings_version

    File c:\\Users\\cmont\\anaconda3\\Lib\\site-packages\\eccodes\\eccodes.py:12
          1 #
          2 # (C) Copyright 2017- ECMWF.
          3 #
       (...)
         10 #
         11 #
    ---> 12 from gribapi import __version__
         13 from gribapi import bindings_version
         15 from gribapi import GRIB_CHECK as CODES_CHECK

    File c:\\Users\\cmont\\anaconda3\\Lib\\site-packages\\gribapi\\__init__.py:13
          1 #
          2 # (C) Copyright 2017- ECMWF.
          3 #
       (...)
         10 #
         11 #
    ---> 13 from .gribapi import *  # noqa
         14 from .gribapi import __version__
         15 from .gribapi import bindings_version

    File c:\\Users\\cmont\\anaconda3\\Lib\\site-packages\\gribapi\\gribapi.py:32
         29 import os
         30 import numpy as np
    ---> 32 from .bindings import ENC, ffi, lib
         33 from .bindings import __version__ as bindings_version  # noqa
         34 from . import errors

    File c:\\Users\\cmont\\anaconda3\\Lib\\site-packages\\gribapi\\bindings.py:60
         58             pass
         59     if lib is None:
    ---> 60         raise RuntimeError(f\"ecCodes library not found using {LIBNAMES}\")
         62 # default encoding for ecCodes strings
         63 ENC = \"ascii\"

    RuntimeError: ecCodes library not found using ['eccodes', 'libeccodes.so', 'libeccodes']"
    }

  5. it seems this solved my problem

    !pip install ecmwflibs

    thank you very much for taking the time to help me