Stumbleine75
Stumbleine75

Reputation: 401

How to successfully import numpy using Python 3.x?

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.

Upvotes: 3

Views: 2271

Answers (1)

casevh
casevh

Reputation: 11394

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.

Upvotes: 3

Related Questions