ecmwf / eccodes-python

Python interface to the ecCodes GRIB/BUFR decoder/encoder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Loading eccodes on MacOS with M1 chip fails with OSError

leroygr opened this issue · comments

Hi,

I'm trying to install eccodes-python on Mac with M1 chip with MacOs Big Sur. I'm using Python 3.9.5.

I have first build and installed successfully eccodes-c library in /usr/local. Then when install eccodes-python with pip:

$ pip install eccodes

Then I try to load eccodes, I get the following error:

$ python -m eccodes selfcheck
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 188, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 147, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "/Users/gle/dev/3e/dataservices/pipelines/gfs-datasync/eccodes-python-1.3.4/eccodes/__init__.py", line 13, in <module>
    from .eccodes import *  # noqa
  File "/Users/gle/dev/3e/dataservices/pipelines/gfs-datasync/eccodes-python-1.3.4/eccodes/eccodes.py", line 12, in <module>
    from gribapi import (
  File "/Users/gle/dev/3e/dataservices/pipelines/gfs-datasync/eccodes-python-1.3.4/gribapi/__init__.py", line 13, in <module>
    from .gribapi import *  # noqa
  File "/Users/gle/dev/3e/dataservices/pipelines/gfs-datasync/eccodes-python-1.3.4/gribapi/gribapi.py", line 34, in <module>
    from . import errors
  File "/Users/gle/dev/3e/dataservices/pipelines/gfs-datasync/eccodes-python-1.3.4/gribapi/errors.py", line 16, in <module>
    from .bindings import ENC, ffi, lib
  File "/Users/gle/dev/3e/dataservices/pipelines/gfs-datasync/eccodes-python-1.3.4/gribapi/bindings.py", line 45, in <module>
    lib = ffi.dlopen(library_path)
  File "/Users/gle/Envs/gfs-datasync/lib/python3.9/site-packages/cffi/api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "/Users/gle/Envs/gfs-datasync/lib/python3.9/site-packages/cffi/api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "/Users/gle/Envs/gfs-datasync/lib/python3.9/site-packages/cffi/api.py", line 828, in _load_backend_lib
    return backend.load_library(path, flags)
OSError: cannot load library '/usr/local/lib/libeccodes.dylib': dlopen(/usr/local/lib/libeccodes.dylib, 2): no suitable image found.  Did find:
        /usr/local/lib/libeccodes.dylib: mach-o, but wrong architecture
        /usr/local/lib/libeccodes.dylib: mach-o, but wrong architecture

I tried several things, also installing eccodes-python from source but it didn't work.

Could anyone help me with this?

Thanks,
Greg

@leroygr I installed eccodes today on a Macbook Air 2020 M1 -- I needed the ecmwflibs package to make it work:

$ brew install eccodes
$ pip install eccodes
$ pip install ecmwflibs
$ python -m eccodes selfcheck
Found: ecCodes v2.24.0.
Library: /opt/homebrew/anaconda3/envs/contrails/lib/python3.9/site-packages/ecmwflibs/.dylibs/libeccodes.dylib
Definitions: /MEMFS/definitions
Samples: /MEMFS/samples
Your system is ready.

It looks like the libeccodes.dylib is coming from ecmwflibs in this case.

Awesome it worked!

Thanks