numpy in Blender

1,671 views
Skip to first unread message

Emanuele Gissi

unread,
May 13, 2011, 9:58:07 AM5/13/11
to blenderfds
Hi Matthias, hi all,

using NumPy in Blender is easy (for a developer!).

As you know, Blender 2.57 has its own separate installation of Python 3.2.
NumPy shall be installed into that Blender Python.

The simplest way to do that:
1) install NumPy on a local Python 3.2 installation.
2) copy the numpy folder from the lib/python3.2/site-packages subdirectory of your local Python 3.2 installation into the scripts/modules subdirectory of Blender (not into the python/lib/python3.2/site-packages subdirectory; Blender doesn't seem to look there.)

Now run Blender and open a Python console. If you do not know how, ask me.
Test NumPy by typing: import numpy
And your are done.

I suggest we could split the task in two:

1) Mark can begin to look at the algorithm and translate it to NumPy, leaving a fallback mechanism if "import numpy" fails.

2) I will try to ease numpy installation from the BlenderFDS user point of view.
An install script? distributing precompiled numpy for each platform?
Another solution could be to convince Blender to use a local Python 3.2 install, if available, instead of the embedded one.

Matthias, ok?

Best regards,
Emanuele


--
http://www.emanuelegissi.eu/

Emanuele Gissi

unread,
May 13, 2011, 10:06:47 AM5/13/11
to blenderfds
Forgot to add: use the latest numpy-1.6.0rc3.
I had to compile it for Ubuntu as there's no binary available. Not difficult, not too easy.
There is a Windows binary ready to download.
After local installation test it in a Python console before jumping into Blender.
Ema
--
http://www.emanuelegissi.eu/

Matti

unread,
Jun 10, 2011, 3:30:15 AM6/10/11
to blenderfds
Hi Emanuele,

I had a lot of work, so I had no time for Blender. The next weeks I
will have more time for Blender.

Can you give me a update about the numpy algorithm.
Had Mark translated the algorithm into numpy?

Should I support Mark?


Regards

Matti


On 13 Mai, 16:06, Emanuele Gissi <emanuele.gi...@gmail.com> wrote:
> Forgot to add: use the latest numpy-1.6.0rc3.
> I had to compile it for Ubuntu as there's no binary available. Not
> difficult, not too easy.
> There is a Windows binary ready to download.
> After local installation test it in a Python console before jumping into
> Blender.
> Ema
>
> On Fri, May 13, 2011 at 3:58 PM, Emanuele Gissi <emanuele.gi...@gmail.com>wrote:
>
>
>
>
>
> > Hi Matthias, hi all,
>
> > using NumPy in Blender is easy (for a developer!).
>
> > As you know, Blender 2.57 has its own separate installation of Python 3.2.
> > NumPy shall be installed into that Blender Python.
>
> > The simplest way to do that:
> > 1) install NumPy on a local Python 3.2 installation.
> > 2) copy the numpy folder from the lib/python3.2/site-packages subdirectory
> > of your local Python 3.2 installation into the scripts/modulessubdirectory of Blender (
> > *not* into the python/lib/python3.2/site-packages subdirectory; Blender
> > doesn't seem to look there.)
>
> > Now run Blender and open a Python console. If you do not know how, ask me.
> > Test NumPy by typing: import numpy
> > And your are done.
>
> > I suggest we could split the task in two:
>
> > 1) Mark can begin to look at the algorithm and translate it to NumPy,
> > leaving a fallback mechanism if "import numpy" fails.
>
> > 2) I will try to ease numpy installation from the BlenderFDS user point of
> > view.
> > An install script? distributing precompiled numpy for each platform?
> > Another solution could be to convince Blender to use a local Python 3.2
> > install, if available, instead of the embedded one.
>
> > Matthias, ok?
>
> > Best regards,
> > Emanuele
>
> > --
> >http://www.emanuelegissi.eu/
>
> --http://www.emanuelegissi.eu/- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Emanuele Gissi

unread,
Jun 10, 2011, 4:12:46 AM6/10/11
to blend...@googlegroups.com
Hi Matti,

1) Well, having a lot of work in a crisis period is good news, isn't it?
The crisis is still biting hard here in Italy. I know that German situation is better.
(http://www.emanuelegissi.eu/search/label/Bad%20news)

2) Ops, It was a mistake. In fact, "Mark" was you: s/Mark/Matti
I intended to propose that you could begin to look at the algorithm.
But, take your time, we are not in a hurry.

Next week I'll be on the Alps, far away from any internet connection.

Best regards,
Emanuele
--
http://www.emanuelegissi.eu/

Matti

unread,
Jun 10, 2011, 5:58:11 AM6/10/11
to blenderfds

Hi Emanuele,

Yes, the German situation is in fact better.
German companys profit from the good situation and so they will build
new buildings. And so I can do a lot of simulatIons with FDS.
A view of my projects are very interresting. E.g. I simulatetd a
building with 70.000 m².


I will translate the algorithm the next weeks.

I wish you a view nice days in the alps.


Matti



On 10 Jun., 10:12, Emanuele Gissi <emanuele.gi...@gmail.com> wrote:
> Hi Matti,
>
> 1) Well, having a lot of work in a crisis period is good news, isn't it?
> The crisis is still biting hard here in Italy. I know that German situation
> is better.
> (http://www.emanuelegissi.eu/search/label/Bad%20news)
>
> 2) Ops, It was a mistake. In fact, "Mark" was you: s/Mark/Matti
> I intended to propose that you could begin to look at the algorithm.
> But, take your time, we are not in a hurry.
>
> Next week I'll be on the Alps, far away from any internet connection.
>
> Best regards,
> Emanuele
>
> On Fri, Jun 10, 2011 at 9:30 AM, Matti
> <matthias.zaehrin...@googlemail.com>wrote:
> > > --http://www.emanuelegissi.eu/-Zitierten Text ausblenden -

Matti

unread,
Jun 21, 2011, 6:15:31 AM6/21/11
to blenderfds
Hi Emanuele,

i tried to install numpy under MacOS.
For my local python installation it will work perfect.

In blender-python i get an error:

>>> import numpy
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "/Applications/Blender/blender.app/Contents/MacOS/2.57/scripts/
modules/numpy/__init__.py", line 128, in <module>
from version import git_revision as __git_revision__
ImportError: No module named version

Do you know, if numpy has any dependences?


Matti
> > > > --http://www.emanuelegissi.eu/-ZitiertenText ausblenden -

Emanuele Gissi

unread,
Jun 21, 2011, 8:54:31 AM6/21/11
to blend...@googlegroups.com
Hi Matti,
it seems that the Blender embedded Python for Mac lacks the "version" module.
Try copying it from the local Python 3.2 installation into the scripts/modules dir.
I can't check now, I'll give a look this evening at home (if children permit ;-).
Ema
--
http://www.emanuelegissi.eu/

Matti

unread,
Jun 27, 2011, 4:03:53 AM6/27/11
to blenderfds
Hi Emanuele,

don't work.

Other ideas?

Matti

On 21 Jun., 14:54, Emanuele Gissi <emanuele.gi...@gmail.com> wrote:
> Hi Matti,
> it seems that the Blender embedded Python for Mac lacks the "version"
> module.
> Try copying it from the local Python 3.2 installation into the
> scripts/modules dir.
> I can't check now, I'll give a look this evening at home (if children permit
> ;-).
> Ema
>
> On Tue, Jun 21, 2011 at 12:15 PM, Matti
> <matthias.zaehrin...@googlemail.com>wrote:
> > > > > > --http://www.emanuelegissi.eu/-ZitiertenTextausblenden -

Emanuele Gissi

unread,
Jun 27, 2011, 4:52:00 AM6/27/11
to blend...@googlegroups.com
Hi Matti,
I am far from home and can't try it directly for at least 2 weeks.
Sorry, I'll help you when I am back home...
Emanuele
--
http://www.emanuelegissi.eu/

Emanuele Gissi

unread,
Jul 4, 2011, 2:00:49 AM7/4/11
to blend...@googlegroups.com
Here is a hint:
http://wiki.blender.org/index.php/User:Ideasman42/ImportExport_TODO

Several other developers share our concerns about Blender exporting speed.
Let's follow what ideas they propose...

Emanuele
--
http://www.emanuelegissi.eu/

Emanuele Gissi

unread,
Jul 10, 2011, 9:41:25 AM7/10/11
to blend...@googlegroups.com, Matthias Zähringer
Hi Matthias,
I am back home.
I tested numpy install in Blender. It still works for me.

I followed the following easier procedure:
1) install locally python 3.2 from www.python.org
2) install locally numpy 1.6.1rc2 from http://new.scipy.org/download.html (get the appropriate binary for your platform)
3) Launch Python 3.2 and check numpy (eg: "import numpy")
4) copy numpy folder from Python 3.2 site packages to Blender/2.58/python/modules
Check permission!
5) launch Blender 2.58, open a Python console and type "import numpy"
(What's a Python console? see: http://wiki.blender.org/index.php/Doc:2.5/Manual/Extensions/Python/Console)

This should work on Windows and MacOSX
I have got one or two ideas on how to automate this.

Emanuele
--
http://www.emanuelegissi.eu/

Matti

unread,
Jul 11, 2011, 2:05:21 AM7/11/11
to blenderfds
Hi Emanuele,

i tried your ideas.
For blender path for mac is a different than the windows path.

I get this error, typing "import numpy":

Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "/Applications/Blender/blender.app/Contents/MacOS/2.57/scripts/
modules/numpy/__init__.py", line 128, in <module>
from version import git_revision as __git_revision__
File "/Applications/Blender/blender.app/Contents/MacOS/2.57/scripts/
modules/version.py", line 30, in <module>
from types import StringType
ImportError: cannot import name StringType

I use Blender 2.57 at the moment. I will test it with the 2.58
Version.

Matthias


On 10 Jul., 15:41, Emanuele Gissi <emanuele.gi...@gmail.com> wrote:
> Hi Matthias,
> I am back home.
> I tested numpy install in Blender. It still works for me.
>
> I followed the following easier procedure:
> 1) install locally python 3.2 fromwww.python.org
> 2) install locally numpy 1.6.1rc2 fromhttp://new.scipy.org/download.html(getthe appropriate binary for your
> platform)
> 3) Launch Python 3.2 and check numpy (eg: "import numpy")
> 4) copy numpy folder from Python 3.2 site packages to
> Blender/2.58/python/modules
> Check permission!
> 5) launch Blender 2.58, open a Python console and type "import numpy"
> (What's a Python console? see:http://wiki.blender.org/index.php/Doc:2.5/Manual/Extensions/Python/Co...)
>
> This should work on Windows and MacOSX
> I have got one or two ideas on how to automate this.
>
> Emanuele
>
> On Mon, Jul 4, 2011 at 8:00 AM, Emanuele Gissi <emanuele.gi...@gmail.com>wrote:
>
>
>
>
>
> > Here is a hint:
> >http://wiki.blender.org/index.php/User:Ideasman42/ImportExport_TODO
>
> > Several other developers share our concerns about Blender exporting speed.
> > Let's follow what ideas they propose...
>
> > Emanuele
>
> > On Mon, Jun 27, 2011 at 10:52 AM, Emanuele Gissi <emanuele.gi...@gmail.com

Matti

unread,
Jul 11, 2011, 2:15:23 AM7/11/11
to blenderfds
Version 2.58:

Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "/Applications/Blender_2.58/blender.app/Contents/MacOS/2.58/
scripts/modules/numpy/__init__.py", line 128, in <module>
from version import git_revision as __git_revision__
ImportError: No module named version


Matthias


On 11 Jul., 08:05, Matti <matthias.zaehrin...@googlemail.com> wrote:
> Hi Emanuele,
>
> i tried your ideas.
> For blender path for mac is a different than the windows path.
>
> I get this error, typing "import numpy":
>
> Traceback (most recent call last):
>   File "<blender_console>", line 1, in <module>
>   File "/Applications/Blender/blender.app/Contents/MacOS/2.57/scripts/
> modules/numpy/__init__.py", line 128, in <module>
>     from version import git_revision as __git_revision__
>   File "/Applications/Blender/blender.app/Contents/MacOS/2.57/scripts/
> modules/version.py", line 30, in <module>
>     from types import StringType
> ImportError: cannot import name StringType
>
> I use Blender 2.57 at the moment. I will test it with the 2.58
> Version.
>
> Matthias
>
> On 10 Jul., 15:41, Emanuele Gissi <emanuele.gi...@gmail.com> wrote:
>
>
>
> > Hi Matthias,
> > I am back home.
> > I tested numpy install in Blender. It still works for me.
>
> > I followed the following easier procedure:
> > 1) install locally python 3.2 fromwww.python.org
> > 2) install locally numpy 1.6.1rc2 fromhttp://new.scipy.org/download.html(gettheappropriate binary for your

Emanuele Gissi

unread,
Jul 11, 2011, 5:35:12 AM7/11/11
to blend...@googlegroups.com
I think it's a compilation problem.

Try the following:
1) check if the  scripts/modules/numpy/version.py file exists.

2a) If it exists, then send it to me.

2b) if it does not exist add a version.py file with the following content:
short_version='1'
version='1'
git_revision='123'
release=True

Now test numpy again, please.

Emanuele
--
http://www.emanuelegissi.eu/

Matti

unread,
Jul 11, 2011, 6:39:10 AM7/11/11
to blenderfds
version.py:


# THIS FILE IS GENERATED FROM NUMPY SETUP.PY
short_version = '1.6.1rc1'
version = '1.6.1rc1'
full_version = '1.6.1rc1'
git_revision = 'b11e3af9487cf3342bbad742231c312a02398f91'
release = True

if not release:
version = full_version


With your content the same error.

Matthias




On 11 Jul., 11:35, Emanuele Gissi <emanuele.gi...@gmail.com> wrote:
> I think it's a compilation problem.
>
> Try the following:
> 1) check if the  scripts/modules/numpy/version.py file exists.
>
> 2a) If it exists, then send it to me.
>
> 2b) if it does not exist add a version.py file with the following content:
> short_version='1'
> version='1'
> git_revision='123'
> release=True
>
> Now test numpy again, please.
>
> Emanuele
>
> On Mon, Jul 11, 2011 at 8:15 AM, Matti
> <matthias.zaehrin...@googlemail.com>wrote:
> > new.scipy.org/download.html(gettheappropriate<http://new.scipy.org/download.html%28gettheappropriate>binary for your
> -- ...
>
> Erfahren Sie mehr »

Emanuele Gissi

unread,
Jul 11, 2011, 7:52:20 AM7/11/11
to blend...@googlegroups.com
In file "/Applications/Blender/blender.app/Contents/MacOS/2.57/scripts/modules/numpy/__init__.py", line 128

replace:

from version import git_revision as __git_revision__
with:
from .version import git_revision as __git_revision__
(note the dot before version)
(we will surely encounter the same problem elsewhere)

If this does not work, try this:

replace:

from version import git_revision as __git_revision__
with:
__git_revision__ = 'b11e3af9487cf3342bbad742231c312a02398f91'

It seems that Blender cannot find the version.py file.
It's rather strange...
Emanuele
--
http://www.emanuelegissi.eu/

Matti

unread,
Jul 12, 2011, 1:41:05 AM7/12/11
to blenderfds
new Error:

Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "/Applications/Blender_2.58/blender.app/Contents/MacOS/2.58/
scripts/modules/numpy/__init__.py", line 133, in <module>
from _import_tools import PackageLoader
ImportError: No module named _import_tools

I think there is problem with the import of modules.

I will completely reinstall python, numpy and blender and test it
again.

Matthias

On 11 Jul., 13:52, Emanuele Gissi <emanuele.gi...@gmail.com> wrote:
> In file
> "/Applications/Blender/blender.app/Contents/MacOS/2.57/scripts/modules/nump y/__init__.py",
> line 128
>
> replace:
> from version import git_revision as __git_revision__
> with:
> from .version import git_revision as __git_revision__
> (note the dot before version)
> (we will surely encounter the same problem elsewhere)
>
> If this does not work, try this:
>
> replace:
> from version import git_revision as __git_revision__
> with:
> __git_revision__ = 'b11e3af9487cf3342bbad742231c312a02398f91'
>
> It seems that Blender cannot find the version.py file.
> It's rather strange...
> Emanuele
>
> On Mon, Jul 11, 2011 at 12:39 PM, Matti
> <matthias.zaehrin...@googlemail.com>wrote:
> ...
>
> Erfahren Sie mehr »

Emanuele Gissi

unread,
Jul 12, 2011, 2:22:06 AM7/12/11
to blend...@googlegroups.com
Thank you.
All this seems rather strange.
Emanuele
--
http://www.emanuelegissi.eu/

Matti

unread,
Jul 12, 2011, 3:16:44 AM7/12/11
to blenderfds
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "/Applications/Blender_2.58/blender.app/Contents/MacOS/2.58/
python/lib/python3.2/numpy/__init__.py", line 137, in <module>
from . import add_newdocs
File "/Applications/Blender_2.58/blender.app/Contents/MacOS/2.58/
python/lib/python3.2/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/Applications/Blender_2.58/blender.app/Contents/MacOS/2.58/
python/lib/python3.2/numpy/lib/__init__.py", line 4, in <module>
from .type_check import *
File "/Applications/Blender_2.58/blender.app/Contents/MacOS/2.58/
python/lib/python3.2/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/Applications/Blender_2.58/blender.app/Contents/MacOS/2.58/
python/lib/python3.2/numpy/core/__init__.py", line 5, in <module>
from . import multiarray
ImportError: cannot import name multiarray

On 12 Jul., 08:22, Emanuele Gissi <emanuele.gi...@gmail.com> wrote:
> Thank you.
> All this seems rather strange.
> Emanuele
>
> On Tue, Jul 12, 2011 at 7:41 AM, Matti
> <matthias.zaehrin...@googlemail.com>wrote:
> ...
>
> Erfahren Sie mehr »

Josh Goates

unread,
May 16, 2017, 11:05:02 AM5/16/17
to blenderfds, matthias....@googlemail.com
Matti,
did you ever find a solution for this error? I am having the same problem. I moved the numpy folder to the blender/2.78/scripts/modules folder, but when I run it I get the same error where is says it cannot import name multiarray. Any help is appreciated.
Thanks
Reply all
Reply to author
Forward
0 new messages