How to install numpy

I use Blender 2.57 under Ubuntu 11.04 (64-Bit)

I try to import numpy in a GameLogic Basic Script by using the statement

from numpy import *

but it didn’t work. I received the message “no module named numpy”

what do I do wrong? do i have to install a separate version of numpy inside the blender-directory? I tried to copy the numpy-folder of into 2.57/python/lib/python3.2/ but then I receive the message

ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python intepreter from there.

What do I do wrong?

Yes. Build and install it in the usual way into your standard installation of Python 3.2, then copy the installed version from lib/python3.2/site-packages into 2.57/scripts/modules. Putting it in 2.57/python/lib/python3.2/site-packages should work, but Blender doesn’t seem to find it there.

Best wishes,

ok, thank you for your advise. In Ubuntu I have installed python 2.7 (which seems to be better supported than 3.2). Do I have to upgrade on Python 3.2 or is there any other way to install numpy for python 3.2 in blender?

I’m sure there is another way, but configuring NumPy to install directly into Blender is beyond my expertise. Note that if you do add Python 3.2 to your system, “python” at the command line will still by default invoke 2.7; you need to say “python3” if 3.x is what you want. I imagine it will remain that way until 3.x is more widely supported.

Best wishes,

thank you very much MCollett! It worked!

For other users:

  1. Install python3.2
  2. Install numpy for python3.2 using the python3.2 command instead of python
  3. on my system numpy was located in /usr/local/lib/python3.2/dist-packages. Copy numpy from there to blender/2.57/scripts/modules

I found it works in blender/2.57/scripts/addons/modules also.

Hmm, it doesn’t seem to work with blender v2.64 and numpy-1.8.0, though maybe my numpy install failed somewhere. Blender sees some of it, the full error is

>>> import numpyTraceback (most recent call last):
File “<blender_console>”, line 1, in <module>
File “/Applications/Blender/”, line 137, in <module>
from . import add_newdocs
File “/Applications/Blender/”, line 9, in <module>
from numpy.lib import add_newdoc
File “/Applications/Blender/”, line 4, in <module>
from .type_check import *
File “/Applications/Blender/”, line 8, in <module>
import numpy.core.numeric as _nx
File “/Applications/Blender/”, line 45, in <module>
from numpy.testing import Tester
File “/Applications/Blender/”, line 8, in <module>
from unittest import TestCase
ImportError: No module named unittest

I’m using numpy 1.6.2 successfully in Blender 2.64a release. Not sure what the differences might be between 1.6.2 and 1.8.0.

Windows 7 64bit

As part of the process of installing numpy for Blender, you need to copy the unittest folder from lib/python3.2/site-packages to 2.64/scripts/modules. (Both sides are at fault here: unittest is part of the standard Python library, so it is naughty of Blender Python to omit it; on the other hand, numpy shouldn’t try to load that module unless you actually run the unit tests, which you would not normally do from within Blender.)

Beset wishes,

That’s a great explanation…thank you for taking the time to write the “why” and not just the “what you need to do”