1

I am new to Python and I am trying to install numpy+mkl and scipy (in the same order), but I get below error when I execute following steps:

import pandas as pd  
import numpy as np  
from sklearn.preprocessing import LabelEncoder 

I am using Python 3.5 (32-bit) on a Windows 7 64-bit OS.

There is a similar question already answered for the exact problem here: ImportError: cannot import name NUMPY_MKL

Going through the answer, I reinstalled my numpy+mkl pkg numpy‑1.11.2+mkl‑cp35‑cp35m‑win32.whl from the mentioned link (http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy) and then reinstalled scipy-0.18.1-cp35-cp35m-win32.whl as well, but that does not solve the problem and I still get the same error:

>>> exec(open("C:\\PythonFiles\\testpy1.py").read())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 3, in <module>
  File "C:\Users\msoudagar\AppData\Local\Programs\Python\Python3532\lib\site-packages\sklearn\__init__.py", line 57, in <module>
    from .base import clone
  File "C:\Users\msoudagar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sklearn\base.py", line 10, in <module>
    from scipy import sparse
  File "C:\Users\msoudagar\AppData\Local\Programs\Python\Python3532\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'

Any inputs would be really helpful!

Community
  • 1
  • 1
Mohammed Raqeeb
  • 75
  • 2
  • 12
  • In the error message there's a path with `Python3532` and another with `Python35-32`. That seems fishy. Also, since you're reinstalling, why not use 64-bit python? – user7138814 Nov 20 '16 at 17:28

4 Answers4

1

Try commenting out the line from numpy._distributor_init import NUMPY_MKL it might just work regardless.

ImportError: cannot import name NUMPY_MKL

Community
  • 1
  • 1
Souradeep Nanda
  • 3,116
  • 2
  • 30
  • 44
1

I know this is not the most sophisticated of solutions but, all I had to do was close the IDE(in my case, Pycharm) and re-open it again.

Not sophisticated but effective in my case :).

Tshilidzi Mudau
  • 7,373
  • 6
  • 36
  • 49
1

Check this answer. Solved my problem.

https://stackoverflow.com/a/37294205/2708266

Suggesting to download ready made binary setup from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

pip install xx.whl
Yash
  • 6,644
  • 4
  • 36
  • 26
-1

I ran into the same issue on Windows with Python 3.5 64 bit. Manually installing numpy+mkl from wheel file solved the issue for me. Select the appropriate wheel file from here (cp35,win32 for you): and install it using pip install --user Path_to_local_file.whl replacing Path_to_local_file with wherever you saved the .whl file

This is a also a duplicate of ImportError: cannot import name NUMPY_MKL

K4dse
  • 481
  • 3
  • 4
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/16330081) – Donald Duck Jun 05 '17 at 13:35
  • Thanks for the Feedback. I also just realized this Question is 6 months old.. So my answer is probably not going to be relevant anyway – K4dse Jun 05 '17 at 14:08
  • It doesn't matter if the question is old, you can still answer it. Even if your answer might not help the person who asked the question, it can still help others who are looking for an answer to the same problem and found this question by googling. You're even encouraged to answer old questions, there are badges for that: [Revival](https://stackoverflow.com/help/badges/837/revival) and [Necromancer](https://stackoverflow.com/help/badges/17/necromancer). For more information, you can read [Should I answer an old (inactive) question?](https://meta.stackoverflow.com/q/265642/4284627) – Donald Duck Jun 05 '17 at 14:55