In spite encountering no errors in pygrib installation, I encountered the following error when importing pygrib:
>>> import pygrib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /python/python-2.7.13/lib/python2.7/site-packages/pygrib.so: undefined symbol: __svml_round2_mask
Any advice on what could be causing this "undefined symbol" error?
Undefined symbol errors are usually caused by one of two things:
Incorrect linking
If you are building the pygrib module itself, make sure that the required library dependencies are being properly linked, and in the right order. Based on the missing symbol name,
__svml_round2_mask
, I'd guess yourpygrib.so
was compiled with the Intelicc
C compiler and needs to be linked to the math library containing the SVML (Short Vector Math Library) functions. It's difficult to get more specific without knowing more details of your build environment, but for example, on linux, bothicc
andgcc
(which both call GNUld
for linking) need to have that math library specified on their command line, and it needs to come after the binary or library that is calling it.Evironment mismatch
If pygrib is not being built by you (either explicitly, or as part of a
pip
orconda
install command), then you probably have an environment mismatch. This happens when thepygrib.so
you downloaded was built against different libraries than the ones you have installed. Ideally, all Python binary packages would be built against a very vanilla set of libraries (e.g. the "manylinux1" container for linux wheels) so that they will run on most systems, but sometimes specialized and performance-critical packages need to be built with particular optimizations or against uncommon libraries. If those optimizations or libraries don't match between the build system and the system on which the resulting package is install, theundefined symbol
error can be the result.One way to minimize the occurrence of this is to not mix-and-match package repositories where possible. That is, if you're using Anaconda, only pull packages from Anaconda. I know, not always possible, right?
If you're on linux, it is sometimes possible to figure out where the mismatch is by using the
ldd
command, for example:$ ldd -r /python/python-2.7.13/lib/python2.7/site-packages/pygrib.so
You'll see a bunch of undefined symbols starting with
Py
or_Py
--ignore those, they're supplied by Python itself. But in amongst those, you'll hopefully discover which particular library is needing__svml_round2_mask
. Look at its full path carefully, and the full paths of the other libraries listed, and this might suggest where the mismatch came from.Other suggestions
pygrib
and its dependencies, might enable us to offer more specific advice.pygrib
packages? Conda-forge lists several; one of them might match your system.python-eccodes
module instead? It seems to be the recommended successor to pygrib.Good luck, I hope something in here helps!