Missing /usr/share/metview/lib/x86_64-linux-gnu/libMvMacro.so on Ubuntu
What happened?
Does Metview hard-code the location of this library somewhere?
My "import metview" fails with this error because the libMvMacro.so isn't in this location. The only fix I've found is to manually create that path and softlink the files from libmetview-dev here. Overriding LD_LIBRARY_PATH doesn't take, as presumably something in the library is discarding that.
What are the steps to reproduce the bug?
apt install metview libmetview-dev
pip install metview
python -c "import metview"
Version
5.21.2
Platform (OS and architecture)
Ubuntu 24.04
Relevant log output
OSError: cannot load library '/usr/share/metview/lib/x86_64-linux-gnu/libMvMacro.so': /usr/share/metview/lib/x86_64-linux-gnu/libMvMacro.so: cannot open shared object file: No such file or directory. Additionally, ctypes.util.find_library() did not manage to locate a library called '/usr/share/metview/lib/x86_64-linux-gnu/libMvMacro.so'
Accompanying data
No response
Organisation
No response
Hi @rkarim-nnk, the Metview distribution for Ubuntu is not created by ECMWF, but it seems to split Metview apart in ways that it does not expect :) Metview's Python bindings ask the Metview executable where it's installed and where this library is. But for this Ubuntu package, this information is clearly incorrect. I'm sure that the library is on the system, so if you can find it, then one workaround would be to manually modify this line in metview-python to reflect its actual location. Not ideal, but I'm not familiar enough with where the various parts of Metview are installed to be able to provide a more general solution at the moment.
https://github.com/ecmwf/metview-python/blob/develop/metview/bindings.py#L206
Hi @iainrussell , thanks for your reply, that makes sense. I see that the Ubuntu apt package splits the metview installation over:
- /usr/share/metview/
- /usr/lib/x86_64-linux-gnu/
The call to mi.info("METVIEW_LIB") is clearly returning the first value, but the necessary .so that is obtained by installing libmetview-dev resides in the second.
I see that the code already falls back to the METVIEW_LIB environ variable, but this didn't seem to be applying when I import metview. I'm wondering if executing metview sets this on initialisation and overrides the value somewhere.
A less neat (but probably functional) workaround might be to have the binding read from a METVIEW_LIB_OVERRIDE variable to discard whatever metview returns and have the binding retain ultimate control over where it expects the LIB to be. What do you think?
Hi @rkarim-nnk, yes I was already thinking that this could be a neat enough mechanism - let the user supply an environment variable that would override the default behaviour. It puts some burden on the user, but it does allow them to work with metview-python without changing any code.
Hi
I am trying to get this working on AlmaLinux 8.10. I am not able to use conda in my environment so I built metview from source and installed it, then installed this python module, I can open the graphical application without issue but I get the same error message as in the original post here, see the output from when I run the selfcheck:
python -m metview
MetviewInvoker: Invoking Metview
Starting Metview using these command args:
['metview', '-nocreatehome', '-slog', '-python-serve', '/tmp/tmpdisxh5k3', '381380']
Metview 5.23.1 (2025.11.14) @ Z7-P51-002
Installed in /usr/local/lib/metview-bundle
Error loading Metview/libMvMacro. LD_LIBRARY_PATH=/usr/local/lib/metview-bundle/lib64:
Traceback (most recent call last):
File "/home/e/kod/base-parameter-calculations/.venv/lib64/python3.12/site-packages/metview/bindings.py", line 206, in <module>
lib = ffi.dlopen(os.path.join(mv_lib, "libMvMacro.so"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/e/kod/base-parameter-calculations/.venv/lib64/python3.12/site-packages/cffi/api.py", line 150, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/e/kod/base-parameter-calculations/.venv/lib64/python3.12/site-packages/cffi/api.py", line 834, in _make_ffi_library
backendlib = _load_backend_lib(backend, libname, flags)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/e/kod/base-parameter-calculations/.venv/lib64/python3.12/site-packages/cffi/api.py", line 829, in _load_backend_lib
raise OSError(msg)
OSError: cannot load library '/usr/local/lib/metview-bundle/lib64/libMvMacro.so': libMetview.so: cannot open shared object file: No such file or directory. Additionally, ctypes.util.find_library() did not manage to locate a library called '/usr/local/lib/metview-bundle/lib64/libMvMacro.so'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen runpy>", line 189, in _run_module_as_main
File "<frozen runpy>", line 148, in _get_module_details
File "<frozen runpy>", line 112, in _get_module_details
File "/home/e/kod/base-parameter-calculations/.venv/lib64/python3.12/site-packages/metview/__init__.py", line 44, in <module>
raise exp
File "/home/e/kod/base-parameter-calculations/.venv/lib64/python3.12/site-packages/metview/__init__.py", line 27, in <module>
from . import bindings as _bindings
File "/home/e/kod/base-parameter-calculations/.venv/lib64/python3.12/site-packages/metview/bindings.py", line 216, in <module>
raise exp
File "/home/e/kod/base-parameter-calculations/.venv/lib64/python3.12/site-packages/metview/bindings.py", line 209, in <module>
lib = ffi.dlopen(os.path.join(mv_lib, "libMvMacro"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/e/kod/base-parameter-calculations/.venv/lib64/python3.12/site-packages/cffi/api.py", line 150, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/e/kod/base-parameter-calculations/.venv/lib64/python3.12/site-packages/cffi/api.py", line 834, in _make_ffi_library
backendlib = _load_backend_lib(backend, libname, flags)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/e/kod/base-parameter-calculations/.venv/lib64/python3.12/site-packages/cffi/api.py", line 829, in _load_backend_lib
raise OSError(msg)
OSError: cannot load library '/usr/local/lib/metview-bundle/lib64/libMvMacro': /usr/local/lib/metview-bundle/lib64/libMvMacro: cannot open shared object file: No such file or directory. Additionally, ctypes.util.find_library() did not manage to locate a library called '/usr/local/lib/metview-bundle/lib64/libMvMacro'
MetviewInvoker: Closing Metview
The file does exist in the correct path though:
> file /usr/local/lib/metview-bundle/lib64/libMvMacro.so
/usr/local/lib/metview-bundle/lib64/libMvMacro.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=f9872c7b30fcc24b4685009495f60559708dad80, with debug_info, not stripped
The rights on the file are 755, which should be sufficient. What kind of fix have you implemented for Conda?