Reputation: 13123
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.
Upvotes: 16
Views: 28271
Reputation: 342
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.
Upvotes: 5
Reputation: 133
I fixed this problem with the following steps:
conda
environmentnumpy
within the environmentI was using PyCharm
so to execute (3), I just set the project interpreter to the Python interpreter in the new environment I created in (1).
Upvotes: 0
Reputation: 593
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.
Upvotes: 8
Reputation: 13123
I seem to have gotten numpy
installed for Python 2.7.13
on the Windows 10
64-bit computer using the following steps. I was able to install numpy
for either a 32-bit or a 64-bit version of Python 2.7.13
. Instructions for both are provided.
At the top of this answer are my instructions for 32-bit Python
.
In the middle are my instructions for 64-bit Python
.
At the bottom are my instructions for 64-bit Python
using a wheel file.
I suspect the primary problem in my original post may have arisen from not realizing that apparently the default version of Python
that is downloaded from here (https://www.python.org/downloads/) is 32-bit.
For installing numpy
on 32-bit Python 2.7.13
uninstalled Anaconda
removed Anaconda
from User Variables
in the Environment Variables
window
installed Python 2.7.13
from the official Python website: https://www.python.org/
in command window typed:
C:\users\general1>cd:\python27
Attempted to update pip
in command window although pip
was already up to date:
python -m pip install -U pip
in command window used the following command, which returned a huge number of errors:
pip install numpy
in command window typed:
python -m pip install numpy
Step 7 seems to have worked. It returned the following message:
C:\Python27>python -m pip install numpy
Collecting numpy
Retrying (Retry(total=4, connect=None, read=None, redirect=None))
after connection broken by 'ProtocolError('Connection aborted.',
error(10054, 'An existing connection was forcibly
closed by the remote host'))': /simple/numpy/
Downloading numpy-1.12.0-cp27-none-win32.whl (6.6MB)
100% |################################| 6.6MB 64kB/s
Installing collected packages: numpy
Successfully installed numpy-1.12.0
Opened Python 2.7.13
and typed:
import numpy
Only the command prompt was returned. No errors or warnings were issued.
I have not yet tried to use any code that requires numpy
, but at least it seems to have been installed.
Step 7 says that a 32-bit file was downloaded:
numpy-1.12.0-cp27-none-win32.whl
I do not know whether a 32-bit version of numpy
was installed or a 64-bit version. Perhaps the file is a 64-bit version that was renamed to say it was a 32-bit version as described in my question.
I typed in Python
(from Do I have Numpy 32 bit or 64 bit?):
import numpy.distutils.system_info as sysinfo
sysinfo.platform_bits
32
So, it seems a 32-bit version of numpy
was installed although my Python
is supposed to be a 64-bit version (from here: How do I determine if my python shell is executing in 32bit or 64bit mode on OS X?):
import platform
platform.architecture()[0]
'32bit'
Perhaps in all of the installing and uninstalling of Python
I accidentally installed a 32-bit version the last time. I can try installing Python
again and use the intended 64-bit version this time. Hopefully the same steps above will still work.
Perhaps if I want a 64-bit version of Python 2.7.13
I am to click on the following on the official Python
webpage (here: https://www.python.org/downloads/windows/):
Download Windows x86-64 MSI installer
instead of on the prominent (https://www.python.org/downloads/):
Download Python 2.7.13
I am also curious to know from where the file numpy-1.12.0-cp27-none-win32.whl
was downloaded. I will provide that too if I find out. Maybe it was downloaded from here: https://pypi.python.org/pypi/numpy
For installing numpy
on 64-bit Python 2.7.13
The steps above worked for installing numpy
for what turned out to be a 32-bit version of Python 2.7.13
.
To install numpy for a 64-bit version of Python 2.7.13
I used the following steps:
uninstall Python 2.7.13
Download: python-2.7.13.amd64.msi
by clicking on: Download Windows x86-64 MSI installer
from here: https://www.python.org/downloads/windows/
in command window typed:
C:\users\general1>cd:\python27
Attempted to update pip
in command window although pip
was already up to date:
python -m pip install -U pip
in command window used the following command, which this time did not return any errors:
pip install numpy
which returned:
C:\Python27>pip install numpy
Collecting numpy
Downloading numpy-1.12.0-cp27-none-win_amd64.whl (7.5MB)
100% |################################| 7.5MB 63kB/s
Installing collected packages: numpy
Successfully installed numpy-1.12.0
Opened Python 2.7.13
and typed:
import numpy
No errors or warnings were returned.
Checked whether numpy
was 64-bit or 32-bit. It was 64-bit.
import numpy.distutils.system_info as sysinfo
sysinfo.platform_bits
64
For installing numpy
wheel files in Python 2.7.13
After installing numpy
I tried to install scipy
and received an error: numpy.distutils.system_info.NotFoundError: no lapack/blas resources found
(described here Windows Scipy Install: No Lapack/Blas Resources Found).
I did the following:
Uninstalled Python 2.7.13
Installed Visual Studio Community 2017 RC
as described by drewid (here: Windows Scipy Install: No Lapack/Blas Resources Found)
Installed VCForPython27.msi
also as described by drewid.
Then I received a scipy
error cannot import name NUMPY_MKL
mentioned here (ImportError: cannot import name NUMPY_MKL).
I downloaded the files numpy-1.12.0+mkl-cp27-cp27m-win_amd64.whl
and scipy-0.18.1-cp27-cp27m-win_amd64.whl
from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy as suggested by VMAtm.
Then I:
uninstall Python 2.7.13
Reinstall Python 2.7.13
using python-2.7.13.amd64.msi
Installed numpy-1.12.0+mkl-cp27-cp27m-win_amd64.whl
from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy using the following line in the command window:
pip install numpy-1.12.0+mkl-cp27-cp27m-win_amd64.whl
Installed scipy-0.18.1-cp27-cp27m-win_amd64.whl
from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy using the following line in the command window
pip install scipy-0.18.1-cp27-cp27m-win_amd64.whl
Both numpy
and scipy
can now import inside Python 2.7.13
Note that I placed scipy-0.18.1-cp27-cp27m-win_amd64.whl
and numpy-1.12.0+mkl-cp27-cp27m-win_amd64.whl
in the folder c:\Python27
prior to using the aforementioned pip
commands.
C:\>cd\Python27
C:\Python27>pip install numpy-1.12.0+mkl-cp27-cp27m-win_amd64.whl
Processing c:\python27\numpy-1.12.0+mkl-cp27-cp27m-win_amd64.whl
Installing collected packages: numpy
Successfully installed numpy-1.12.0+mkl
C:\Python27>pip install scipy-0.18.1-cp27-cp27m-win_amd64.whl
Processing c:\python27\scipy-0.18.1-cp27-cp27m-win_amd64.whl
Installing collected packages: scipy
Successfully installed scipy-0.18.1
C:\Python27>
Upvotes: 3