Cfgrib is not installed correctly on WSL2 through pip

2k Views Asked by At

I'm trying to install cfgrib to my WSL2 Ubuntu however when I type python3 -m cfgrib selfcheck it gives the following error as follows.

Traceback (most recent call last):
  File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/messages.py", line 42, in <module>
    import pyeccodes.compat as eccodes
ModuleNotFoundError: No module named 'pyeccodes'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 184, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.8/runpy.py", line 143, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/python3.8/runpy.py", line 110, in _get_module_details
    __import__(pkg_name)
  File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/__init__.py", line 19, in <module>
    from .cfmessage import CfMessage
  File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/cfmessage.py", line 29, in <module>
    from . import messages
  File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/messages.py", line 44, in <module>
    raise exc
  File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/messages.py", line 37, in <module>
    from . import bindings as eccodes
  File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/bindings.py", line 57, in <module>
    raise RuntimeError(f"ecCodes library not found using {LIBNAMES}")
RuntimeError: ecCodes library not found using ['eccodes', 'libeccodes.so', 'libeccodes']

My python version is Python 3.8.2. Is it possible to install cfgrib through pip?

1

There are 1 best solutions below

1
On

The latest release of cfgrib version 0.9.8.5 at PyPI doesn't declare eccodes or pyeccodes as a dependency, not even as extra. You can install one of them separately:

pip install eccodes

or

pip install pyeccodes

(I don't know what is the difference; cfgrib can use both).

The bug is fixed in the repository but not yet released to PyPI so you can try to install the latest version using git:

pip install --upgrade "git+https://github.com/ecmwf/cfgrib.git#egg=cfgrib"