I am new to Python
and am attempting unsuccessfully to install numpy
. The current problem is an error message reading, in part, Importing the multiarray numpy extension module failed
. I cannot locate this error message on the internet and am asking for help. The complete error message is at the bottom of this post.
First I thought I should provide system and version details and describe what I have done. I am running Windows 10
on a 64-bit machine and have installed Python 2.7.13
from https://www.python.org/downloads/windows/
I have also installed Anaconda
, also for Python 2.7
and a 64-bit machine, downloaded from here https://www.continuum.io/downloads. Anaconda
runs Python 2.7.12
, rather than Python 2.7.13
. When I type import numpy
inside the Anaconda
GUI IPython
no errors or warnings appear. Nevertheless, I have the impression running numpy
from inside Python 2.7.13
using IDLE (Python GUI)
might be computationally faster. Python 2.7.13
appears first in my Path statement.
I downloaded numpy-1.12.0rc2+mkl-cp27-cp27m-win_amd64.whl
from http://www.lfd.uci.edu/~gohlke/pythonlibs/#jpype Following suggestions from this post installing numpy from wheel format on windows ( not a supported wheel on this platform.) I renamed:
numpy-1.12.0rc2+mkl-cp27-cp27m-win_amd64.whl
to:
numpy-1.12.0rc2+mkl-cp27-none-win32.whl
manually by clicking on the name and editing it. The renamed file is in the folder C:\Python27
Then I used the Windows command window (cmd) to update pip
typing:
python -m pip install --upgrade pip
A message said pip
was already up-to-date.
Then I typed the following in the cmd window:
pip install numpy-1.12.0rc2+mkl-cp27-none-win32.whl
A message said: Successfully installed numpy-1.12.0rc2+mkl
. (Prior to doing this I attempted to install the .whl
file using its original name and received an error that the file was not for my platform.)
After installing numpy
in Python 2.7.13
I open Python
and typed:
import numpy
Here is the complete error message that was returned:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import numpy
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 24, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Numerous numpy
folders and files now appear inside C:\Python27
I also tried the following two commands and received the messages shown:
>>> pip show numpy
SyntaxError: invalid syntax
>>> git clean -xdf
SyntaxError: invalid syntax
>>>
Sorry that this post is so long, but I do not know which of the above details might be most helpful in diagnosing the problem. I have only been using Python
for about 24 hours and most of that time has been spent attempting to install numpy
into Python 2.7.13
. Mostly I use R
and know some C
. I have not attempted to install any other Python
libraries or packages. Perhaps I am missing dependencies required by numpy
. Thank you for any advice or assistance with this problem. If I can provide additional information please let me know. Sorry if this is a duplicate.
NumPy Installation On Windows Operating System You can download the required version of python from python.org. Once python is installed successfully, open command prompt and use pip to install numpy.
The Python "ModuleNotFoundError: No module named 'numpy'" occurs when we forget to install the numpy module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install numpy command.
In my case this issue was related to numpy. So, I removed the numpy and again installed it. To remove numpy if you already have conda environment can we done by conda remove numpy
if this command is removing some other packages also which are dependent on numpy then in the same environment if pip is installed, numpy can be removed using pip pip uninstall numpy
and to again download it use pip install numpy
. This should probably fix your error.
This issue was discussed extensively over on https://github.com/numpy/numpy/issues/9272 with a workaround solution which worked for me. It's pertinent to the Anaconda environment I believe you have.
Quoting: tobigithub commented on Jul 23, 2017. @njsmith thank you, I just confirmed using a VM on a clean Windows 10 system that has never seen Intel MKL DLLs, numpy or conda, all things are fine and numpy works. I am just puzzled how numpy suddenly stopped working, could be third parties. Probably needs some more digging, lets see what we can find out to make numpy ironclad to any dependency issue.
The solution is indeed related to some DLL depencency issues under WIN with Intel MKL libraries the numpy import error was under python 3.6.2 and numpy 1.13.1 :
"import numpy" numpy\core_init_.py", line 16, in from . import multiarray ImportError: DLL load failed: The specified procedure could not be found.
The quick and dirty solution is to copy all Intel mkl*.dll libraries from the specific environments (env) subfolder (seen at stackoverflow)
<\Library\bin> to <\Lib\site-packages\numpy\core>
04/13/2017 12:50 AM 30,277,392 mkl_avx.dll
04/13/2017 12:50 AM 38,253,840 mkl_avx2.dll
04/13/2017 12:50 AM 42,234,640 mkl_avx512.dll
04/13/2017 12:50 AM 45,722,896 mkl_avx512_mic.dll
04/13/2017 12:50 AM 25,369,360 mkl_core.dll
04/13/2017 12:50 AM 24,541,456 mkl_def.dll
04/13/2017 12:50 AM 24,506,640 mkl_intel_thread.dll
04/13/2017 12:50 AM 29,744,400 mkl_mc.dll
04/13/2017 12:50 AM 30,594,320 mkl_mc3.dll
04/13/2017 12:50 AM 12,567,824 mkl_rt.dll
04/13/2017 12:50 AM 11,388,688 mkl_sequential.dll
04/13/2017 12:50 AM 12,575,504 mkl_tbb_thread.dll
04/13/2017 12:50 AM 11,250,960 mkl_vml_avx.dll
04/13/2017 12:50 AM 11,463,952 mkl_vml_avx2.dll
04/13/2017 12:50 AM 10,285,840 mkl_vml_avx512.dll
04/13/2017 12:50 AM 11,692,304 mkl_vml_avx512_mic.dll
04/13/2017 12:50 AM 5,224,208 mkl_vml_cmpt.dll
04/13/2017 12:50 AM 5,345,552 mkl_vml_def.dll
04/13/2017 12:50 AM 9,477,904 mkl_vml_mc.dll
04/13/2017 12:50 AM 9,368,336 mkl_vml_mc2.dll
04/13/2017 12:50 AM 9,593,616 mkl_vml_mc3.dll
now numpy can be imported and runs fine. One last thing, the best approach is to match compatible versions of Python and numpy, which of course change as releases are made. See [numpy compatibility index] (https://numpy.org/neps/nep-0029-deprecation_policy.html) for up to date compatibility information. Don't forget to match scipy and matplotlib versions to numpy as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With