Sage 5.1: Animate command bug

i like this post (click again to cancel)
0
i dont like this post (click again to cancel)

Hi all,

I have installed the both the app version and the command line version of the Sage 5.1 on a MacBook Pro running Lion. Also, I have installed the most recent version of ImageMagick and I've set the environment variables as suggested at the ImageMagick website. I also checked that ImageMagick is working!

Sage's 'animate' command fails when invoking either version of Sage 5.1 from the command line and then entering "notebook" command to start the browser version of Sage.

The example is the first one in the 'Animate Plots' section of the Sage's 'Help':

a = animate([circle((i,i), 1-1/(i+1), hue=i/10) for i in srange(0,2,0.2)], xmin=0,ymin=0,xmax=2,ymax=2,figsize=[2,2]) a.show() # optional -- ImageMagick

Below is the error that is reported by Sage:

============================================================================ convert: memory allocation failed 00000000.png' @ error/png.c/ReadOnePNGImage/2105. convert: corrupt image00000000.png' @ error/png.c/ReadPNGImage/3693. convert: memory allocation failed 00000001.png' @ error/png.c/ReadOnePNGImage/2105. convert: corrupt image00000001.png' @ error/png.c/ReadPNGImage/3693. convert: memory allocation failed 00000002.png' @ error/png.c/ReadOnePNGImage/2105. convert: corrupt image00000002.png' @ error/png.c/ReadPNGImage/3693. convert: memory allocation failed 00000003.png' @ error/png.c/ReadOnePNGImage/2105. convert: corrupt image00000003.png' @ error/png.c/ReadPNGImage/3693. convert: memory allocation failed 00000004.png' @ error/png.c/ReadOnePNGImage/2105. convert: corrupt image00000004.png' @ error/png.c/ReadPNGImage/3693. convert: memory allocation failed 00000005.png' @ error/png.c/ReadOnePNGImage/2105. convert: corrupt image00000005.png' @ error/png.c/ReadPNGImage/3693. convert: memory allocation failed 00000006.png' @ error/png.c/ReadOnePNGImage/2105. convert: corrupt image00000006.png' @ error/png.c/ReadPNGImage/3693. convert: memory allocation failed 00000007.png' @ error/png.c/ReadOnePNGImage/2105. convert: corrupt image00000007.png' @ error/png.c/ReadPNGImage/3693. convert: memory allocation failed 00000008.png' @ error/png.c/ReadOnePNGImage/2105. convert: corrupt image00000008.png' @ error/png.c/ReadPNGImage/3693. convert: memory allocation failed 00000009.png' @ error/png.c/ReadOnePNGImage/2105. convert: corrupt image00000009.png' @ error/png.c/ReadPNGImage/3693. convert: no images defined `/private/var/folders/31/r_2f8ryd5ks7xb80nyrbj2cc0000gn/T/tmpbsWwH9/sage\ 0.gif' @ error/convert.c/ConvertImageCommand/3044. Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_2.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -- coding: utf-8 --\n" + _support_.preparse_worksheet_cell(base64.b64decode("YSA9IGFuaW1hdGUoW2NpcmNsZSgoaSxpKSwgMS0xLyhpKzEpLCBodWU9aS8xMCkgZm9yIGkgaW4gc3JhbmdlKDAsMiwwLjIpXSwgCiAgICAgICAgICAgICAgIHhtaW49MCx5bWluPTAseG1heD0yLHltYXg9MixmaWdzaXplPVsyLDJdKQphLnNob3coKSAjIG9wdGlvbmFsIC0tIEltYWdlTWFnaWNr"),globals())+"\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in <module>

File "/private/var/folders/31/r_2f8ryd5ks7xb80nyrbj2cc0000gn/T/tmpyUOMOA/___code___.py", line 5, in <module> exec compile(u'a.show() # optional -- ImageMagick File "", line 1, in <module>

File "/Applications/Sage/local/lib/python2.7/site-packages/sage/plot/animate.py", line 457, in show self.gif(delay = delay, iterations = iterations) File "/Applications/Sage/local/lib/python2.7/site-packages/sage/plot/animate.py", line 400, in gif raise OSError, msg OSError: Error: Neither ImageMagick nor ffmpeg appears to be installed. Saving an animation to a GIF file or displaying an animation requires one of these packages, so please install one of them and try again.

See www.imagemagick.org and www.ffmpeg.org for more information.

This might be a permissions error (which causes the images not to be generated) or perhaps a 64bit vs 32bit lib error. I am not sure!

Note that if the app version of Sage is invoked, Sage is unable to find ImageMagick's "convert" command.

In a previous response to a similar question it was suggested that one should modify the "environment.plist" file to set the environment variables rather than the ".bash_profile file". However, the problem above seems to be more serious than just finding ImageMagick.

In any case, there should be a better fix than this! An average user should not be expected to make such changes in their systems! In future versions of Sage could ImageMagick (or an equivalent) be bundled with Sage?

Regards,

Adam Hausknecht Department of Mathematics UMass Dartmouth

asked Jul 13 '12

this post is marked as community wiki

This post is a wiki. Anyone with karma >150 is welcome to improve it.

updated Jul 13 '12

ahausknecht gravatar image ahausknecht
21 5

It works for me using Snow Leopard and ImageMagick installed via home brew. You can see if it's a permissions issue by checking permissions of sage.misc.misc.tmp_dir(). That should also help find the generated pngs (they will be in a sibling directory) and you can see if they are corrupted. I would also try running convert from within sage -sh since that should mimic the environment used by sage. You may need to use sage-native-execute convert ... to reset PATH, and LD_LIBRARY_PATH, etc.

Ivan Andrus (Jul 13 '12)
i like this answer (click again to cancel)
1
i dont like this answer (click again to cancel)

Hi all,

I tried Ivan Andrus's suggestion (see above) and have discovered that there is a problem with the latest version of ImageMagick. When I downgraded to "ImageMagick-6.7.5" from "ImageMagick-6.7.8" (the current version), the "animate" does work in Sage 5.1 when Sage is started from the Terminal !

It seems that "ImageMagick-6.7.8 was built against a different version of "libpng" than was "ImageMagick-6.7.5" and this is causing the memory errors.

Thanks and regards,

Adam Hausknecht Department of Mathematics UMass Dartmouth

link

answered Jul 13 '12

this post is marked as community wiki

This post is a wiki. Anyone with karma >150 is welcome to improve it.

updated Jul 13 '12

ahausknecht gravatar image ahausknecht
21 5

Yikes! That is a nasty thing. Can you give us more details? I think we do assume libpng is on the system, but I don't know that we verify the "right" version. Maybe we need to check this :(

kcrisman (Jul 13 '12)

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

Tags:

Stats:

Asked: Jul 13 '12

Seen: 125 times

Last updated: Jul 13 '12

powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.