ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 19 Nov 2011 13:54:23 -0600Compiling R with PNG supporthttps://ask.sagemath.org/question/7754/compiling-r-with-png-support/I just compiled sage 4.6 from source on an Ubuntu 10.04 machine. I have the xorg-dev packages installed. However, I still cannot get r to save the plot of a histogram. Specifically, I am getting:
sage: r.png('/tmp/histogram.png')
RuntimeError: R was not compiled with PNG support
What *does* work is:
sage: r.X11()
sage: r.hist("rnorm(100)")
But I can't save the resulting graphic. (Of course, I can print-screen and get it that way, but I was hoping there would be a better way.) Can I compile R with PNG support somehow? Or is there another workaround which will give me what I want (namely, saving a picture of a histogram)?
Thanks.Sun, 07 Nov 2010 11:24:19 -0600https://ask.sagemath.org/question/7754/compiling-r-with-png-support/Answer by Jason Grout for <p>I just compiled sage 4.6 from source on an Ubuntu 10.04 machine. I have the xorg-dev packages installed. However, I still cannot get r to save the plot of a histogram. Specifically, I am getting:</p>
<pre><code>sage: r.png('/tmp/histogram.png')
RuntimeError: R was not compiled with PNG support
</code></pre>
<p>What <em>does</em> work is:</p>
<pre><code>sage: r.X11()
sage: r.hist("rnorm(100)")
</code></pre>
<p>But I can't save the resulting graphic. (Of course, I can print-screen and get it that way, but I was hoping there would be a better way.) Can I compile R with PNG support somehow? Or is there another workaround which will give me what I want (namely, saving a picture of a histogram)?</p>
<p>Thanks.</p>
https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?answer=12308#post-id-12308I solved this on Ubuntu by installing the `libpango1.0-dev` and `libcairo-dev` packages. I had also earlier installed the `xorg-dev` package, but I don't know if it is actually needed here.
Thu, 21 Apr 2011 05:41:48 -0500https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?answer=12308#post-id-12308Answer by Volker Braun for <p>I just compiled sage 4.6 from source on an Ubuntu 10.04 machine. I have the xorg-dev packages installed. However, I still cannot get r to save the plot of a histogram. Specifically, I am getting:</p>
<pre><code>sage: r.png('/tmp/histogram.png')
RuntimeError: R was not compiled with PNG support
</code></pre>
<p>What <em>does</em> work is:</p>
<pre><code>sage: r.X11()
sage: r.hist("rnorm(100)")
</code></pre>
<p>But I can't save the resulting graphic. (Of course, I can print-screen and get it that way, but I was hoping there would be a better way.) Can I compile R with PNG support somehow? Or is there another workaround which will give me what I want (namely, saving a picture of a histogram)?</p>
<p>Thanks.</p>
https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?answer=12913#post-id-12913I just made a new r spkg at http://trac.sagemath.org/sage_trac/ticket/12057 which should help with graphics. Please test if you can and leave your feedback on the trac page.Sat, 19 Nov 2011 10:27:04 -0600https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?answer=12913#post-id-12913Comment by kcrisman for <p>I just made a new r spkg at <a href="http://trac.sagemath.org/sage_trac/ticket/12057">http://trac.sagemath.org/sage_trac/ti...</a> which should help with graphics. Please test if you can and leave your feedback on the trac page.</p>
https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?comment=20855#post-id-20855Yeah, I saw that. Does one need the libpango/libcairo, to your knowledge? Sat, 19 Nov 2011 13:54:23 -0600https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?comment=20855#post-id-20855Answer by Jason Bandlow for <p>I just compiled sage 4.6 from source on an Ubuntu 10.04 machine. I have the xorg-dev packages installed. However, I still cannot get r to save the plot of a histogram. Specifically, I am getting:</p>
<pre><code>sage: r.png('/tmp/histogram.png')
RuntimeError: R was not compiled with PNG support
</code></pre>
<p>What <em>does</em> work is:</p>
<pre><code>sage: r.X11()
sage: r.hist("rnorm(100)")
</code></pre>
<p>But I can't save the resulting graphic. (Of course, I can print-screen and get it that way, but I was hoping there would be a better way.) Can I compile R with PNG support somehow? Or is there another workaround which will give me what I want (namely, saving a picture of a histogram)?</p>
<p>Thanks.</p>
https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?answer=11772#post-id-11772(This should maybe be a comment, but I'm posting as an answer for better formatting.) I just discovered the following:
sage: r.eval('capabilities("png")')
' png \nFALSE '
sage: r.eval('capabilities("X11")')
' X11 \nTRUE '
So apparently, I have X11 support, but not PNG support. Does that suggest anything that I might be able to do?Tue, 09 Nov 2010 02:51:50 -0600https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?answer=11772#post-id-11772Comment by Jason Bandlow for <p>(This should maybe be a comment, but I'm posting as an answer for better formatting.) I just discovered the following:</p>
<pre><code>sage: r.eval('capabilities("png")')
' png \nFALSE '
sage: r.eval('capabilities("X11")')
' X11 \nTRUE '
</code></pre>
<p>So apparently, I have X11 support, but not PNG support. Does that suggest anything that I might be able to do?</p>
https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?comment=22512#post-id-22512This was the key. I did not have libpng installed. I installed it, re-compiled r with sage -f, and everything works. Thanks for your help, everyone!Tue, 09 Nov 2010 04:00:33 -0600https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?comment=22512#post-id-22512Comment by pangard for <p>(This should maybe be a comment, but I'm posting as an answer for better formatting.) I just discovered the following:</p>
<pre><code>sage: r.eval('capabilities("png")')
' png \nFALSE '
sage: r.eval('capabilities("X11")')
' X11 \nTRUE '
</code></pre>
<p>So apparently, I have X11 support, but not PNG support. Does that suggest anything that I might be able to do?</p>
https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?comment=22364#post-id-22364could you be more specific? I apt-get installed xorg-dev and libpng12-dev, then "sage -f"'ed the package r-2...spkg, but then I had no png and no X11 capabilities. (running sage from a ssh console here: were you inside an X11 session?)Fri, 24 Dec 2010 05:09:00 -0600https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?comment=22364#post-id-22364Comment by niles for <p>(This should maybe be a comment, but I'm posting as an answer for better formatting.) I just discovered the following:</p>
<pre><code>sage: r.eval('capabilities("png")')
' png \nFALSE '
sage: r.eval('capabilities("X11")')
' X11 \nTRUE '
</code></pre>
<p>So apparently, I have X11 support, but not PNG support. Does that suggest anything that I might be able to do?</p>
https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?comment=22511#post-id-22511cool! -- glad to helpTue, 09 Nov 2010 04:05:17 -0600https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?comment=22511#post-id-22511Answer by niles for <p>I just compiled sage 4.6 from source on an Ubuntu 10.04 machine. I have the xorg-dev packages installed. However, I still cannot get r to save the plot of a histogram. Specifically, I am getting:</p>
<pre><code>sage: r.png('/tmp/histogram.png')
RuntimeError: R was not compiled with PNG support
</code></pre>
<p>What <em>does</em> work is:</p>
<pre><code>sage: r.X11()
sage: r.hist("rnorm(100)")
</code></pre>
<p>But I can't save the resulting graphic. (Of course, I can print-screen and get it that way, but I was hoping there would be a better way.) Can I compile R with PNG support somehow? Or is there another workaround which will give me what I want (namely, saving a picture of a histogram)?</p>
<p>Thanks.</p>
https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?answer=11771#post-id-11771looking at the variable `SAGE_TMP` will, I think, give you an idea of where the displayed images are being stored -- for me (Mac), all the displayed images are in that directory.
It's mentioned, for example, in the Developer's Guide section about [saving output files in automated tests](http://www.sagemath.org/doc/developer/conventions.html#further-conventions-for-automated-testing-of-examples).
Tue, 09 Nov 2010 02:30:42 -0600https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?answer=11771#post-id-11771Comment by Jason Bandlow for <p>looking at the variable <code>SAGE_TMP</code> will, I think, give you an idea of where the displayed images are being stored -- for me (Mac), all the displayed images are in that directory. </p>
<p>It's mentioned, for example, in the Developer's Guide section about <a href="http://www.sagemath.org/doc/developer/conventions.html#further-conventions-for-automated-testing-of-examples">saving output files in automated tests</a>.</p>
https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?comment=22513#post-id-22513Thanks, I'll try this.Tue, 09 Nov 2010 02:57:14 -0600https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?comment=22513#post-id-22513Answer by kcrisman for <p>I just compiled sage 4.6 from source on an Ubuntu 10.04 machine. I have the xorg-dev packages installed. However, I still cannot get r to save the plot of a histogram. Specifically, I am getting:</p>
<pre><code>sage: r.png('/tmp/histogram.png')
RuntimeError: R was not compiled with PNG support
</code></pre>
<p>What <em>does</em> work is:</p>
<pre><code>sage: r.X11()
sage: r.hist("rnorm(100)")
</code></pre>
<p>But I can't save the resulting graphic. (Of course, I can print-screen and get it that way, but I was hoping there would be a better way.) Can I compile R with PNG support somehow? Or is there another workaround which will give me what I want (namely, saving a picture of a histogram)?</p>
<p>Thanks.</p>
https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?answer=11770#post-id-11770This isn't an answer per se (you and I've discussed this before!), but at least I thought I'd put the following as the relevant Trac ticket: [#8868](http://trac.sagemath.org/sage_trac/ticket/8868).
I am puzzled as to why your Ubuntu installation isn't compiling with png support, though. R install guide says
> libX11, libX11-devel, libXt and libXt-devel.
is needed, but you are right that `xorg-dev` should give you this. In our `spkg-install` it says
if [ -f /usr/include/X11/Xwindows.h ]; then
XSUPPORT=yes
so perhaps that isn't detecting your stuff. Thanks to David Kirkby, we also have
else
if [ "x`uname`" = xSunOS ] && [ -f /usr/X11/lib/libXv.so ] ; then
XSUPPORT=yes
but that only would work on Solaris. We really just need to ask on r-devel about this; r-help has been of no help, but I've been reluctant to join r-devel since I know very little about R internals. But we just need to figure out what R precisely needs to allow png, and then have it compile every time those things are there.
Mon, 08 Nov 2010 13:44:28 -0600https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?answer=11770#post-id-11770Comment by Jason Bandlow for <p>This isn't an answer per se (you and I've discussed this before!), but at least I thought I'd put the following as the relevant Trac ticket: <a href="http://trac.sagemath.org/sage_trac/ticket/8868">#8868</a>.</p>
<p>I am puzzled as to why your Ubuntu installation isn't compiling with png support, though. R install guide says </p>
<blockquote>
<p>libX11, libX11-devel, libXt and libXt-devel.</p>
</blockquote>
<p>is needed, but you are right that <code>xorg-dev</code> should give you this. In our <code>spkg-install</code> it says</p>
<pre><code>if [ -f /usr/include/X11/Xwindows.h ]; then
XSUPPORT=yes
</code></pre>
<p>so perhaps that isn't detecting your stuff. Thanks to David Kirkby, we also have </p>
<pre><code>else
if [ "x`uname`" = xSunOS ] && [ -f /usr/X11/lib/libXv.so ] ; then
XSUPPORT=yes
</code></pre>
<p>but that only would work on Solaris. We really just need to ask on r-devel about this; r-help has been of no help, but I've been reluctant to join r-devel since I know very little about R internals. But we just need to figure out what R precisely needs to allow png, and then have it compile every time those things are there.</p>
https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?comment=22515#post-id-22515I don't think we've discussed this before (maybe that was Jason Grout?). The file /usr/include/X11/Xwindows.h is present on my system; I'll try at some point to take a look at the spkg-install in more detail and see if I can't figure out what is failing. Thanks for pointing out the Trac ticket!Tue, 09 Nov 2010 02:01:42 -0600https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?comment=22515#post-id-22515Comment by kcrisman for <p>This isn't an answer per se (you and I've discussed this before!), but at least I thought I'd put the following as the relevant Trac ticket: <a href="http://trac.sagemath.org/sage_trac/ticket/8868">#8868</a>.</p>
<p>I am puzzled as to why your Ubuntu installation isn't compiling with png support, though. R install guide says </p>
<blockquote>
<p>libX11, libX11-devel, libXt and libXt-devel.</p>
</blockquote>
<p>is needed, but you are right that <code>xorg-dev</code> should give you this. In our <code>spkg-install</code> it says</p>
<pre><code>if [ -f /usr/include/X11/Xwindows.h ]; then
XSUPPORT=yes
</code></pre>
<p>so perhaps that isn't detecting your stuff. Thanks to David Kirkby, we also have </p>
<pre><code>else
if [ "x`uname`" = xSunOS ] && [ -f /usr/X11/lib/libXv.so ] ; then
XSUPPORT=yes
</code></pre>
<p>but that only would work on Solaris. We really just need to ask on r-devel about this; r-help has been of no help, but I've been reluctant to join r-devel since I know very little about R internals. But we just need to figure out what R precisely needs to allow png, and then have it compile every time those things are there.</p>
https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?comment=22514#post-id-22514I thought you were 'ancienthart', so I thought we'd discussed this before.
But if you have this file, it should definitely compile with png support. Weird. Unfortunately, I have no idea how to get the graphic that displays out, other than figuring out where it is (there are canonical temp files for such things, but I don't know exactly where they are).Tue, 09 Nov 2010 02:17:10 -0600https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?comment=22514#post-id-22514Answer by macieksk for <p>I just compiled sage 4.6 from source on an Ubuntu 10.04 machine. I have the xorg-dev packages installed. However, I still cannot get r to save the plot of a histogram. Specifically, I am getting:</p>
<pre><code>sage: r.png('/tmp/histogram.png')
RuntimeError: R was not compiled with PNG support
</code></pre>
<p>What <em>does</em> work is:</p>
<pre><code>sage: r.X11()
sage: r.hist("rnorm(100)")
</code></pre>
<p>But I can't save the resulting graphic. (Of course, I can print-screen and get it that way, but I was hoping there would be a better way.) Can I compile R with PNG support somehow? Or is there another workaround which will give me what I want (namely, saving a picture of a histogram)?</p>
<p>Thanks.</p>
https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?answer=11899#post-id-11899I had a very similar looking problem on Ubuntu 10.04.1 server but it turned out to be the following:
I was running my Sage notebook server through ssh session in a console. This way X11 are not accessible to R and R reports no png/jpg/X11 support with capabilities().
I tried to run Sage through virtual framebuffer (xvfb-run), but it didn't work either (edit: now it works, with sage 4.6.2, go on and try it). The solution i've found was to run Sage under X11 through VNC.Thu, 23 Dec 2010 08:27:50 -0600https://ask.sagemath.org/question/7754/compiling-r-with-png-support/?answer=11899#post-id-11899