3

Similar to How to import numpy in python shell, but with different errors and context.

Now, on to the problem. I successfully installed numpy 1.7.0 with minor hassle, although I had to do some registry editions first, but upon trying to import it in the shell I get this mass of errors:

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.

Note: I used from numpy import *. Nothing like this happens when I import pygame, so what's the problem? I know different modules have different problems (such as having to make registry editions in order to install...). What is wrong and how do I fix the problem? I found similar complaints here.

5
  • Did you install from an .exe installer on SourceForge? I don't see one for 1.7.0 numpy. Could you be using the wrong installer? If building yourself, the error indicates it was a 64-bit build and using 32-bit Python. I used the 1.6.2 installer on Python 3.2 with no problems or hacks. Commented Aug 16, 2012 at 2:14
  • I got mine from here: sourceforge.net/projects/numpy/files/NumPy/1.7.0beta/…. If this doesn't work out I'll try 1.6.2. Commented Aug 16, 2012 at 2:23
  • My bad, I didn't see the 3.2 version at first. It should "just work" like the 1.6.2 version did for me. There are no 64-bit installers, though. Are you using a 64-bit Python install? The error message still indicates a DLL isn't the right type. Commented Aug 16, 2012 at 2:43
  • If you're asking about what Version of python I installed, I think I installed the 64-bit version. However, I've been under the impression that 32-bit modules should work with 64-bit python (right? I don't know for sure, it's pure speculation). Anyway, I installed 1.6.2 and tried to import to no avail. However, I did not get rid of 1.7.0 as I don't see an unistall option. Commented Aug 16, 2012 at 2:48
  • No, if you have the 64-bit Python you need 64-bit extensions. You can run 32-bit Python with 32-bit extensions on 64-bit Windows, though. Commented Aug 16, 2012 at 6:47

1 Answer 1

3

You have a 32 vs 64-bit mismatch between Python and numpy. If you are using a 32-bit version of Python, you must use a 32-bit version of any pre-compiled DLLs. 64-bit versions of Python require a 64-bit version of a library that includes pre-compiled DLLs.

Pure Python libraries aren't impacted but any library that includes compiled code must match must match Python itself.

Sign up to request clarification or add additional context in comments.

3 Comments

This is late, but what should I do then? I installed 1.6.2 but still got the error upon importing numpy. Do I have to get another version of Python because there's only one numpy 1.6.2 for Python 3.2?
You have two choices. To use the official numpy binaries, you'll need to install a 32-bit version of Python. This will limit you memory usage to ~2GB. If you want to stay with a 64-bit version of Python, I would try the numpy binaries available at http://www.lfd.uci.edu/~gohlke/pythonlibs/
Thank you very much, I downloaded and installed the 64 bit numpy MKL 1.6.2 file and I now get no errors when importing numpy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.