Getting NumPy installed for Python 2 or Python 3 in Ubuntu was easy. Getting it to work in Windows turned out to be more tricky.
The Short Takeaway
- In a Windows 7 environment (even a 64-bit Windows 7 environment), you must install the 32-bit version of Python 3. The 64-bit version will not work with NumPy 1.6.
- Furthermore, the 32-bit version of Python 3 must be installed 'just for me', and not 'for everyone on this computer'.
- Finally, make sure you select the proper NumPy version (for Python 3.2), not the default version from SourceForge (which is for Python 2.6).
Step 1: Ensure that NumPy Isn't Already Installed
Open a Python prompt and ensure that you don't already have NumPy installed:>>> from numpy import *
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
from numpy import *
ImportError: No module named numpy
Step 2: Download NumPy from SourceForge
The SourceForge homepage for NumPy can be found at http://sourceforge.net/projects/numpy/. From there find the latest version of NumPy for Windows, and download it to your default download location. For me as write this, that means downloading NumPy 1.6.1. Note that the default SourceForge download link pointed to a version of NumPy compiled for Python 2.6. I had to navigate a bit deeper to find a version for Python 3.Step 3: Open the installation file
Double-click the file from wherever you downloaded it to to start the installation wizard. It's trustworthy open-source software, so it's safe to click through all the prompts and allow it to be installed.This leads us to a crucial error:
It reads: Python version 3.2 required, which was not found in the registry. Yikes. I definitely have Python 3.2, but it's telling me it looked in the Windows registry and couldn't find it. I heard somewhere that installing Python for 'just this user (me)' instead of 'for all users of this computer' is one way to get around this.
Step 4: Reinstall Python 'just for me'
So to comply, I uninstall Python, and reinstall it, being careful to install it 'just for me' as shown below.Step 5: Try installing NumPy again
With Python 3.2.3(64-bit) reinstalled properly, I try the NumPy installer again. This time it finds Python in the registry (presumably), and installs NumPy 1.6 without issue. Now test it out.Step 6: Test out NumPy
To make sure it installed correctly, go into the Python interpreter and try importing NumPy:from numpy import *This returns the following mess:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from numpy import *
File "C:\Python32\lib\site-packages\numpy\__init__.py", line 137, in <module>
from . import add_newdocs
File "C:\Python32\lib\site-packages\numpy\add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "C:\Python32\lib\site-packages\numpy\lib\__init__.py", line 4, in <module>
from .type_check import *
File "C:\Python32\lib\site-packages\numpy\lib\type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "C:\Python32\lib\site-packages\numpy\core\__init__.py", line 5, in <module>
from . import multiarray
ImportError: DLL load failed: %1 is not a valid Win32 application
The last line is telling: "not a valid Win32 application." Some of the online forums seem to suggest that it could be a problem with 64-bit Python. Here's the exact version I'm running: "Python 3.2.3 (default, Apr 11 2012, 07:12:16) [MSC v.1500 64 bit (AMD64)] on win32".
Step 7: Uninstall 64-bit Python, install 32-bit Python
So I'm going to uninstall NumPy and uninstall this 64-bit version of Python 3.2.3, and in its place install a 32-bit version of Python 3.2.3. Again, be careful to install 'just for me.' When this is done, I have this version installed: "Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win32". Now try NumPy again.Step 8: Try installing NumPy again
Using the same NumPy binary as every time before, re-install it. To re-cap, I'm installing this in the context of a 32-bit Python 3.2.3 installation. I get no errors from the installation of NumPy, so it's time to test it.Step 9: Test NumPy
One more time, in the Python interpreter, try importing NumPy:>>> from numpy import *This time it returns nothing, meaning it worked! Try creating a NumPy array, and see if it returns the proper type:
type(array([1,6,3,7]))
<class 'numpy.ndarray'>That worked too, which means our task of installing NumPy for Python 3 in Windows 7 has been completed.
Conclusion
Here are the condensed steps for getting NumPy to work with Python 3 in Windows 7- Regardless of whether you have a 32-bit or a 64-bit operating system, install the 32-bit version of Python 3.2
- Make sure you have installed Python 3.2 'just for me', and not 'for all users of this computer'.
- Make sure you download the correct version of NumPy from SourceForge, not the default that it offers as the latest version (which is for Python 2.6 instead of Python 3)


Thank you very much. This was an extremely useful post!
ReplyDeleteYou're welcome. Glad it helped.
DeleteAlso very grateful for your guidance!
ReplyDeleteThanks for this useful information.
ReplyDeleteThank you :))
ReplyDeleteI've spent a few days fighting this. Thanks for taking the time to help us all out!
ReplyDeletethank so much
ReplyDeletethis exactly helped me a lot
this also works with Python 3.3 and numpy-1.7.0-win32-superpack-python3.3.exe
DeleteI love you! :D
ReplyDeleteVery useful post!
ReplyDeleteThank you so much for the walkthrough =D
This helped me a lot. Thanks!
ReplyDelete