William Bell
William Bell

Reputation: 177

Intel MKL Error preventing me importing Scipy in Python

I am attempting to use scipy.integrate.solve_ivp, but the problem occurs with any import statement requiring scipy, including something as simple as:

import scipy

When I run this, I receive the following error:

INTEL MKL ERROR:
   dlopen(/Users/user/.conda/envs/nephron/lib/libmkl_intel_thread.dylib, 9): 
   Library not loaded: @rpath/libiomp5.dylib
   Referenced from: /Users/user/.conda/envs/nephron/lib/libmkl_intel_thread.dylib
   Reason: no suitable image found.  Did find:
    /Users/user/.conda/envs/nephron/bin/../lib/libiomp5.dylib: file too short.
Intel MKL FATAL ERROR: Cannot load libmkl_intel_thread.dylib.

I am using the Pycharm Community IDE (version 2019.2.3) with Anaconda plugin (but it happens even with I execute the script just in my terminal), and Python version 3.7.5 on a MacBook Air running macOS High Sierra 10.13.6. My package manager is conda 4.7.12. EDIT: I have scipy version 1.3.1 installed.

I have not been able to find an explanation for this error on Stack or Google after a brief search, I have tried seeing if it was missing my installation of the package, but I looked upon the search paths being used by Python within Pycharm (as tested by running python -V in the terminal in Pycharm, indeed it occurs if I run it just through my normal Terminal), and indeed scipy was installed along one of the search paths.

EDIT:

I tried creating a new environment, removing the existing one, with conda create -n nephron scipy, this did not fix the problem.

Thank you to another user for adding a relevant tag.

Same problem appears to occur with other some other intel packages, such as numpy.

Upvotes: 4

Views: 5471

Answers (2)

net_programmer
net_programmer

Reputation: 372

I had the same issue when I installed seaborn after having installed months ago scipy. Scipy installed the mkl=2019 package and the newest version of seaborn required mkl=2020.

What I did was just deleting both scipy, seaborn and mkl=2019 and then I reinstalled them from conda.

Upvotes: 2

srilekha palepu - Intel
srilekha palepu - Intel

Reputation: 2253

The root cause maybe NumPy,SciPy is unable to load the correct MKL or Intel OpenMP runtime libraries. This is almost always caused by one of two things:

  1. The environment with NumPy or SciPy has not been activated.

  2. Another software vendor has installed MKL or Intel OpenMP (libiomp5md.dll) files into the C:\Windows\System32 folder. These files are being loaded before Anaconda's and they're not compatible.

Try to set environment or do preload dll etc.

Here is Linux

export LD_PRELOAD=/opt/intel/mkl/lib/intel64/libmkl_def.so:/opt/intel/mkl/lib/intel64/libmkl_avx2.so:/opt/intel/mkl/lib/intel64/libmkl_core.so:/opt/intel/mkl/lib/intel64/libmkl_intel_lp64.so:/opt/intel/mkl/lib/intel64/libmkl_intel_thread.so:/opt/intel/lib/intel64_lin/libiomp5.so

In windows, setting env by mkl/bin/mklvars.bat intel64, then run your python in same environment

or in python to add the library manually sys.path.append(" your path to the library") or Pyinstaller numpy "Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll"...

Upvotes: 0

Related Questions