Intel MKL error using Conda and matplotlib: "Library not loaded: @rpath/libiomp5.dylib" on macOS

Viewed 2915

I'm using a conda environment for a project and when I install matplotlib I get the following error when attempting to run python:

(conda environment path)/bin/python (Project path)/src/__init__.py
INTEL MKL ERROR: dlopen((conda environment path)/lib/libmkl_intel_thread.dylib, 9): Library not loaded: @rpath/libiomp5.dylib
  Referenced from: (conda environment path)/lib/libmkl_intel_thread.dylib
  Reason: image not found.
Intel MKL FATAL ERROR: Cannot load libmkl_intel_thread.dylib.

I've looked everywhere for a solution, and it seems like the vast majority of similar issues have been on windows, with no accepted solution for macOS. It looks like it seems to be an issue with my DYLD_LIBRARY_PATH environment variable, which is currently empty. If that is the case I don't know how to populate it.

1 Answers

I had the same issue. Something broke when I install pytorch, which I think must've updated or changed some of the MKL libraries.

I tried the solution proposed in the comments (kudos to @cel) by trying to install llvm-openmp but it didn't immediately work because the package was already installed. However, one further step fixed the issues at my end (forcing a reinstall).

conda install -c conda-forge llvm-openmp --force-reinstall
Related