mayavi in sage, howto

199 views
Skip to first unread message

Ondrej Certik

unread,
Mar 5, 2009, 11:10:41 PM3/5/09
to sage-...@googlegroups.com, enthou...@mail.enthought.com
Hi,

I spent last couple days figuring out how to get mayavi2 installed
into Sage, using offscreen rendering (e.g. so that you can use mayavi
from ipython over ssh, without X), so that it can be used in the
notebook easily. It was a lot of pain, so here is the howto so that
you can build on my work:

64bit
-----

wget http://sage.math.washington.edu/home/ondrej/spkg/mesa-7.2.spkg
wget http://sage.math.washington.edu/home/ondrej/spkg/vtk-cvs.spkg
wget http://sage.math.washington.edu/home/ondrej/spkg/reportlab-2.2.spkg
wget http://sage.math.washington.edu/home/ondrej/spkg/swig-1.3.31.spkg
wget http://sage.math.washington.edu/home/ondrej/spkg/wxPython-2.8.9.1.spkg
wget http://sage.math.washington.edu/home/ondrej/spkg/ets-3.1.1.rev23061.spkg
wget http://sage.math.washington.edu/home/ondrej/spkg/mayavi_install

export MAKE="make -j10"
bash mayavi_install

32bit
-----

Instead of mesa-7.2, use:

wget http://sage.math.washington.edu/home/ondrej/spkg/mesa32bit-7.2.spkg

Notes:

* I suggest you look into the mayavi_install script and execute the
commands in there by hand. If some of them fail, install the missing
libs --- but I tested it on several computers (and both 32bit and
64bit archs) in clean sage 3.2.3 and it seems to work, but you may
need some X dev libs installed
* the mesa.spkg has a different install script for 32 and 64 bits, so
just use the correct spkg for your arch. any help in merging the two
packages is greately appreciated
* the ets package will *not* install without a net connection. I learn
this the hard way, by downloading all the stuff, going to a
presentation and then realizing, I can't install ets if I am not
connected to the net, as it tries and needs to download something from
the net. Well, you don't want to know what I was saying at the time.
:)
* this still needs lots of polishing, but it gets the job done already

This would not be possible without Prabhu and Gael, who both fixed
things almost immediatelly after I reported them, thanks a lot! And
thanks also to Jaap, who have helped me a lot over IRC and prepared
the original packages that I just customized to work offscreen using
Prabhu tips, thanks Jaap, it helped me a lot.

Ondrej

Ondrej Certik

unread,
Mar 5, 2009, 11:51:08 PM3/5/09
to enthou...@mail.enthought.com, sage-...@googlegroups.com
On Thu, Mar 5, 2009 at 11:27 PM, Prabhu Ramachandran
<pra...@aero.iitb.ac.in> wrote:

> On 03/06/09 09:40, Ondrej Certik wrote:
>> Hi,
>>
>> I spent last couple days figuring out how to get mayavi2 installed
>> into Sage, using offscreen rendering (e.g. so that you can use mayavi
>> from ipython over ssh, without X), so that it can be used in the
>> notebook easily. It was a lot of pain, so here is the howto so that
>> you can build on my work:
>>
> [...]
>
> Thats very cool Ondrej! Thanks. With more work, we could either write a
>  VTK to Pmesh exporter for jmol or add javascript to animate the view
> to some extent.  Unfortunately, I don't have the time for this ATM. This
> would be awesome so if someone has the time and is interested I'd be
> happy to help and offer pointers.  If there are things we can do in
> mayavi to help make this easier, Gael and I will be happy to add them in
> the code.

Yep, that be awesome. I am just starting to use the Sage notebook for
my things, but my advisor is very excited about the possibilities and
I expect we will do much work on this in the future. Right now I am
just putting all the tools together and trying things. Btw, here is my
first blogpost with very short videos of some regular people on the
scipy/sage/mpl lists. :)

http://ondrejcertik.blogspot.com/2009/03/siam-2009-conference-in-miami-part-i.html

Ondrej

Prabhu Ramachandran

unread,
Mar 5, 2009, 11:37:27 PM3/5/09
to sage-...@googlegroups.com
On 03/06/09 09:40, Ondrej Certik wrote:
> Hi,
>
> I spent last couple days figuring out how to get mayavi2 installed
> into Sage, using offscreen rendering (e.g. so that you can use mayavi
> from ipython over ssh, without X), so that it can be used in the
> notebook easily. It was a lot of pain, so here is the howto so that
> you can build on my work:
>
[...]

Thats very cool Ondrej! Thanks. With more work, we could either write a
VTK to Pmesh exporter for jmol or add javascript to animate the view
to some extent. Unfortunately, I don't have the time for this ATM. This
would be awesome so if someone has the time and is interested I'd be
happy to help and offer pointers. If there are things we can do in
mayavi to help make this easier, Gael and I will be happy to add them in
the code.

cheers,
prabhu

Ondrej Certik

unread,
Mar 6, 2009, 12:53:00 AM3/6/09
to sage-...@googlegroups.com, enthou...@mail.enthought.com
On Thu, Mar 5, 2009 at 11:10 PM, Ondrej Certik <ond...@certik.cz> wrote:
> Hi,
>
> I spent last couple days figuring out how to get mayavi2 installed
> into Sage, using offscreen rendering (e.g. so that you can use mayavi
> from ipython over ssh, without X), so that it can be used in the
> notebook easily. It was a lot of pain, so here is the howto so that

Ok, here is a proof, that it works in the notebook:

http://nb.hpfem.org/home/pub/12/

The error messages are very annoying though. Prabhu, do you know how
to fix it? But it works, that's the most important.

Ondrej

Ondrej Certik

unread,
Mar 6, 2009, 1:44:35 AM3/6/09
to sage-...@googlegroups.com, enthou...@mail.enthought.com

Ok, I fixed that by commenting the warning messages in the C++ file
and reuploaded the spkg package. Well. :)

Anyway, now it looks good:

http://nb.hpfem.org/home/pub/12/

Ondrej

Prabhu Ramachandran

unread,
Mar 6, 2009, 2:15:15 AM3/6/09
to enthou...@mail.enthought.com, sage-...@googlegroups.com
On 03/06/09 12:14, Ondrej Certik wrote:
>> The error messages are very annoying though. Prabhu, do you know how
>> to fix it? But it works, that's the most important.
>
> Ok, I fixed that by commenting the warning messages in the C++ file
> and reuploaded the spkg package. Well. :)

Right, thats the way to do it for now. I'll try and get this into VTK
cvs in the weekend, might take me a bit since I'm behind on several things.

> Anyway, now it looks good:
>
> http://nb.hpfem.org/home/pub/12/

Unfortunately, it renders the html as text/plain for me with Firefox, so
I just see the text. :(

cheers,
prabhu

Prabhu Ramachandran

unread,
Mar 6, 2009, 2:41:53 AM3/6/09
to enthou...@mail.enthought.com, sage-...@googlegroups.com

Answering myself, I added the force HTML bookmarklet that fixes the problem:

http://www.howtocreate.co.uk/bookmarklets.html

After I do that it works fine. However, it might be nice to fix this be
default by changing the content type response?

cheers,
prabhu

Ondrej Certik

unread,
Mar 6, 2009, 2:48:16 AM3/6/09
to sage-...@googlegroups.com, enthou...@mail.enthought.com

That's weird, it works for me and I also use firefox. Do you know how
I can reproduce the problem?

Ondrej

Prabhu Ramachandran

unread,
Mar 6, 2009, 3:14:15 AM3/6/09
to sage-...@googlegroups.com, enthou...@mail.enthought.com
On 03/06/09 13:18, Ondrej Certik wrote:
>> After I do that it works fine. However, it might be nice to fix this be
>> default by changing the content type response?
>
> That's weird, it works for me and I also use firefox. Do you know how
> I can reproduce the problem?

Unfortunately, I have no idea. I am running Firefox 3.0.3 on Ubuntu 8.04.

cheers,
prabhu

Jason Grout

unread,
Mar 6, 2009, 6:29:49 AM3/6/09
to sage-...@googlegroups.com, enthou...@enthought.com


This is a known issue (at least the general issue). See
http://trac.sagemath.org/sage_trac/ticket/4547 for a patch that is
awaiting someone to review a fix for the general issue.

Jason


Jaap Spies

unread,
Mar 6, 2009, 3:15:35 PM3/6/09
to sage-...@googlegroups.com, enthou...@enthought.com, sage-...@googlegroups.com
Ondrej Certik wrote:
> Hi,
>
> I spent last couple days figuring out how to get mayavi2 installed
> into Sage, using offscreen rendering (e.g. so that you can use mayavi
> from ipython over ssh, without X), so that it can be used in the
> notebook easily. It was a lot of pain, so here is the howto so that
> you can build on my work:
[...]

>
> This would not be possible without Prabhu and Gael, who both fixed
> things almost immediatelly after I reported them, thanks a lot! And
> thanks also to Jaap, who have helped me a lot over IRC and prepared
> the original packages that I just customized to work offscreen using
> Prabhu tips, thanks Jaap, it helped me a lot.
>

Some questions:

1) Do you need more than just mayavi2 from the ETS? If you only need mayavi2
there are a lot less dependencies: only vtk and wxPython IIRC.

2) Why do you need vtk-cvs (vtk-5.3)? Is vtk-5.2.1 failing somehow?

3) Why do you install your own osmesa? Can't you trust a standard system
wide install?

Cheers,

Jaap


> Ondrej

Prabhu Ramachandran

unread,
Mar 6, 2009, 10:34:23 PM3/6/09
to sage-...@googlegroups.com, enthou...@enthought.com
On 03/07/09 01:45, Jaap Spies wrote:
> Some questions:
>
> 1) Do you need more than just mayavi2 from the ETS? If you only need mayavi2
> there are a lot less dependencies: only vtk and wxPython IIRC.

In addition, you can install mayavi2 without any dependency on Envisage
or the traits UI backends (i.e. no wxPython + TraitsBackendWX
+Envisage*) -- the trouble in that approach is that you will only get
the offscreen capabilities and none of the UI goodies even if you want
them for some reason outside a notebook. But I would imagine this is a
useful case for some. The way to get that with standard Python is to
simply do: easy_install Mayavi. This should only pull in the basic
package. If you do easy_install Mayavi[app], it pulls in the other
components for the UI/app.

> 2) Why do you need vtk-cvs (vtk-5.3)? Is vtk-5.2.1 failing somehow?

I guess 5.2.1 would work but I did the experimentation with the build on
VTK cvs which is what I had handy. Ondrej also commented out a few
warning lines in his spkg. I'll try and get that into VTK cvs before
5.4 is released (CVS is currently frozen).

> 3) Why do you install your own osmesa? Can't you trust a standard system
> wide install?

Simply because it did not work for some reason. I suspect that the
standard system wide install builds with dri and that for some currently
unfathomable reason does not work cleanly with osmesa -- instead
bundling your own mesa+osmesa almost always works.

Overall, if there is a user base for the full UI and the offscreen,
perhaps two separate bundles might be useful.

cheers,
prabhu

Reply all
Reply to author
Forward
0 new messages