Library not loaded: '@rpath/libiomp5.dylib'

Yesterday, I noticed that one of my Github workflows (involving numba), which was successfully executing before, was now unexpectedly failing for Python 3.9 with the following error:

$ python -c “from numba.np.ufunc import omppool”

Traceback (most recent call last):
File “”, line 1, in
ImportError: dlopen(/Users/runner/hostedtoolcache/Python/3.9.17/x64/lib/python3.9/site-packages/numba/np/ufunc/omppool.cpython-39-darwin.so, 0x0002): Library not loaded: ‘@rpath/libiomp5.dylib’
Referenced from: ‘/Users/runner/hostedtoolcache/Python/3.9.17/x64/lib/python3.9/site-packages/numba/np/ufunc/omppool.cpython-39-darwin.so’
Reason: tried: ‘/Users/ci/miniconda3/envs/numba-ci/envs/testenv_8f3f63b2-cafa-4000-b840-be4d8f80b9d3/lib/libiomp5.dylib’ (no such file), ‘/Users/ci/miniconda3/envs/numba-ci/envs/testenv_8f3f63b2-cafa-4000-b840-be4d8f80b9d3/lib/libiomp5.dylib’ (no such file), ‘/Users/ci/miniconda3/envs/numba-ci/envs/testenv_8f3f63b2-cafa-4000-b840-be4d8f80b9d3/lib/libiomp5.dylib’ (no such file), ‘/Users/ci/miniconda3/envs/numba-ci/envs/testenv_8f3f63b2-cafa-4000-b840-be4d8f80b9d3/lib/libiomp5.dylib’ (no such file), ‘/Users/ci/miniconda3/envs/numba-ci/envs/testenv_8f3f63b2-cafa-4000-b840-be4d8f80b9d3/lib/libiomp5.dylib’ (no such file), ‘/Users/ci/miniconda3/envs/numba-ci/envs/testenv_8f3f63b2-cafa-4000-b840-be4d8f80b9d3/lib/libiomp5.dylib’ (no such file), ‘/usr/local/lib/libiomp5.dylib’ (no such file), ‘/usr/lib/libiomp5.dylib’ (no such file)

  1. It is having trouble finding libiomp5.dylib but this seems to only affect Python 3.9 and not Python [3.8, 3.10, 3.11]
  2. While libomp is already installed, libiomp5.dylib doesn’t seem to be located in the usual places (i.e., /usr/lib or /usr/local/lib)
  3. If somebody can help me locate libiomp5.dylib within the Github Actions environment then I can redirect omppool.cpython-39-darwin.so to point to the right @rpath on my own

Lastly, for easier reproducibility, I’ve created the following public numba test repo along with the aforementioned Github Actions workflow. The corresponding failing Github Actions workflow output is here.

I would appreciate any help or guidance for resolving this.

To resolve this, I had to add the following to my Github Workflow (for MacOS environments):

if [ "$RUNNER_OS" == "macOS" ]; then
    conda install -c intel -y openmp
    ls "$(python -c 'import site; print(site.getsitepackages()[0])')"/numba/np/ufunc/omppool.*.so | xargs install_name_tool -change @rpath/libiomp5.dylib $CONDA/lib/libiomp5.dylib
    python -c "from numba.np.ufunc import omppool"
fi