question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot import newest eccodes version

See original GitHub issue

cfgrib cannot import the newest version of eccodes. Might of course be a eccodes issue but I am not sure how I can get to the bottom of that. To reproduce:

conda install python=3.7 eccodes=2.19.0 cfgrib
import cfgrib

Traceback:

In [1]: import cfgrib
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
~/conda/envs/xarray_dev/lib/python3.8/site-packages/cfgrib/bindings.py in <module>
     55     try:
---> 56         lib = ffi.dlopen(libname)
     57         LOG.info("ecCodes library found using name '%s'.", libname)

~/conda/envs/xarray_dev/lib/python3.8/site-packages/cffi/api.py in dlopen(self, name, flags)
    149         with self._lock:
--> 150             lib, function_cache = _make_ffi_library(self, name, flags)
    151             self._function_caches.append(function_cache)

~/conda/envs/xarray_dev/lib/python3.8/site-packages/cffi/api.py in _make_ffi_library(ffi, libname, flags)
    831     backend = ffi._backend
--> 832     backendlib = _load_backend_lib(backend, libname, flags)
    833     #

~/conda/envs/xarray_dev/lib/python3.8/site-packages/cffi/api.py in _load_backend_lib(backend, name, flags)
    826             msg = "%s.  Additionally, %s" % (first_error, msg)
--> 827         raise OSError(msg)
    828     return backend.load_library(path, flags)

OSError: ctypes.util.find_library() did not manage to locate a library called 'libeccodes'

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
~/conda/envs/xarray_dev/lib/python3.8/site-packages/cfgrib/messages.py in <module>
     36     else:
---> 37         from . import bindings as eccodes
     38 except RuntimeError:

~/conda/envs/xarray_dev/lib/python3.8/site-packages/cfgrib/bindings.py in <module>
     93 #
---> 94 CODES_TYPE_UNDEFINED = lib.GRIB_TYPE_UNDEFINED
     95 CODES_TYPE_LONG = lib.GRIB_TYPE_LONG

~/conda/envs/xarray_dev/lib/python3.8/site-packages/cfgrib/bindings.py in __getattr__(self, attr)
     42     def __getattr__(self, attr):
---> 43         raise RuntimeError(self.message) from self.exc
     44 

RuntimeError: ecCodes library not found on the system.

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-30e689ead031> in <module>
----> 1 import cfgrib

~/conda/envs/xarray_dev/lib/python3.8/site-packages/cfgrib/__init__.py in <module>
     17 
     18 # cfgrib core API depends on the ECMWF ecCodes C-library only
---> 19 from .cfmessage import CfMessage
     20 from .dataset import Dataset, DatasetBuildError, open_file, open_fileindex
     21 from .messages import Message, FileStream

~/conda/envs/xarray_dev/lib/python3.8/site-packages/cfgrib/cfmessage.py in <module>
     27 import numpy as np  # noqa
     28 
---> 29 from . import messages
     30 
     31 LOG = logging.getLogger(__name__)

~/conda/envs/xarray_dev/lib/python3.8/site-packages/cfgrib/messages.py in <module>
     37         from . import bindings as eccodes
     38 except RuntimeError:
---> 39     import pyeccodes.compat as eccodes
     40 
     41 eccodes_version = eccodes.codes_get_api_version()

ModuleNotFoundError: No module named 'pyeccodes'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
iainrussellcommented, Oct 19, 2020

Excellent, thanks for testing so quickly! It was @shahramn who did the work, I just relayed the message 😃 If it’s ok, I’ll close this issue.

1reaction
iainrussellcommented, Oct 19, 2020

Just to let you know, we are preparing an update to eccodes so that it installs to ‘lib’ on conda, at least for now

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't load ecCodes library using python - Stack Overflow
I am using Windows 10 and Python 3.7.6 Any thougths what is wrong? Full error: import eccodes Traceback (most recent call last): File...
Read more >
eccodes - PyPI
Python 3 interface to decode and encode GRIB and BUFR files via the ECMWF ecCodes library. Features: reads and writes GRIB 1 and...
Read more >
ecCodes version 2.26.0 released - ECMWF Confluence Wiki
Changes for Version 2.26.0: New Features/Improvements. [ECC-1375] - GRIB2: Add key to allow alternativeRowScanning to be turned off/on ...
Read more >
satpy: FTBFS: E RuntimeError: Cannot find the ecCodes library
Source: satpy Version: 0.36.0-1 Severity: serious Justification: ... satpy/readers/seviri_l2_bufr.py:41: in <module> > import eccodes as ec ...
Read more >
pygrib Changelog - PyUp.io
move private eccodes dir inside 'share', so `import eccodes` doesn't import an empty ... g2clib_src/enc_jpeg2000.c (no longer available in latest version of
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found