6

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.

  • Can you share the contents of the environment? – AMC Jul 15 '20 at 02:39
  • 7
    `libiomp5.dylib` is provided by conda-forge's `llvm-openmp`. It would probably be possible to workaround by doing `conda install -c conda-forge llvm-openmp`. Then again it makes sense to see the content of the environment as @AMC suggested, to understand how you got there. – cel Jul 15 '20 at 07:11
  • @cel That... seems to have worked. Strange. – ImportAntigrav Jul 15 '20 at 16:29

1 Answers1

3

I had the same issue. Something broke when I installed 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
Daniel
  • 11,332
  • 9
  • 44
  • 72
  • I'm one of the unlucky ones for whom neither the original comment nor this answer worked. Having this issue with a fresh anaconda install when trying to run a macOS app created by PyInstaller. – doublefelix Oct 14 '22 at 11:33