Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name NUMPY_MKL

I am trying to run the following simple code

import scipy
scipy.test()

But I am getting the following error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 586, in runfile
    execfile(filename, namespace)
  File "C:/Users/Mustafa/Documents/My Python Code/SpectralGraphAnalysis/main.py", line 8, in <module>
    import scipy
  File "C:\Python27\lib\site-packages\scipy\__init__.py", line 61, in <module>
    from numpy._distributor_init import NUMPY_MKL  # requires numpy+mkl
ImportError: cannot import name NUMPY_MKL

I am using python 2.7 under windows 10.

I have installed scipy but that does not seem to solve the problem

Any help is appreciated.

like image 694
Steve Avatar asked May 17 '16 04:05

Steve


2 Answers

If you look at the line which is causing the error, you'll see this:

from numpy._distributor_init import NUMPY_MKL  # requires numpy+mkl

This line comment states the dependency as numpy+mkl (numpy with Intel Math Kernel Library). This means that you've installed the numpy by pip, but the scipy was installed by precompiled archive, which expects numpy+mkl.

This problem can be easy solved by installation for numpy+mkl from whl file from here.

like image 134
VMAtm Avatar answered Nov 17 '22 06:11

VMAtm


Reinstall numpy-1.11.0_XXX.whl (for your Python) from www.lfd.uci.edu/~gohlke/pythonlibs. This file has the same name and version if compare with the variant downloaded by me earlier 29.03.2016, but its size and content differ from old variant. After re-installation error disappeared.

Second option - return back to scipy 0.17.0 from 0.17.1

P.S. I use Windows 64-bit version of Python 3.5.1, so can't guarantee that numpy for Python 2.7 is already corrected.

like image 14
Andrew Avatar answered Nov 17 '22 06:11

Andrew