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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Stumbleine75
  • 391
  • 2
  • 7
  • 22
  • 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. – Mark Tolonen Aug 16 '12 at 02:14
  • I got mine from here: http://sourceforge.net/projects/numpy/files/NumPy/1.7.0beta/numpy-1.7.0.dev-f93774d-win32-superpack-python3.2.exe/download. If this doesn't work out I'll try 1.6.2. – Stumbleine75 Aug 16 '12 at 02: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. – Mark Tolonen Aug 16 '12 at 02: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. – Stumbleine75 Aug 16 '12 at 02: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. – Mark Tolonen Aug 16 '12 at 06:47

1 Answers1

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.

casevh
  • 11,093
  • 1
  • 24
  • 35
  • 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? – Stumbleine75 Aug 17 '12 at 05:34
  • 1
    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/](http://www.lfd.uci.edu/~gohlke/pythonlibs/) – casevh Aug 17 '12 at 05:51
  • 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. – Stumbleine75 Aug 17 '12 at 06:29