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.sowas compiled with the InteliccC 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, bothiccandgcc(which both call GNUldfor 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
piporcondainstall command), then you probably have an environment mismatch. This happens when thepygrib.soyou 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 symbolerror 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
lddcommand, for example:$ ldd -r /python/python-2.7.13/lib/python2.7/site-packages/pygrib.soYou'll see a bunch of undefined symbols starting with
Pyor_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
pygriband its dependencies, might enable us to offer more specific advice.pygribpackages? Conda-forge lists several; one of them might match your system.python-eccodesmodule instead? It seems to be the recommended successor to pygrib.Good luck, I hope something in here helps!