Re: Shiny server example 1 Error: unable to start device PNG?

2,658 views
Skip to first unread message

Joe Cheng

unread,
May 14, 2013, 3:43:02 AM5/14/13
to shiny-...@googlegroups.com
What Linux distribution and version are you using? Are you able to start R from the command line and successfully run the png() function?


On Mon, May 13, 2013 at 2:08 AM, Bobby Madamanchi <akmada...@gmail.com> wrote:
Hi,

I've been able to install everything for shiny-server as described in the tutorial, however the examples that require graphical outputs (such as 01_hello and 04_mpg) are not showing the graphs they are supposed to, and instead shows Error  Unable to start device PNG

I expect that this may be related to a flaw in the way i compiled R 2.15.3?  Does anyone have a suggestion?

thanks,
bobby

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Bobby Madamanchi

unread,
May 15, 2013, 1:58:30 AM5/15/13
to shiny-...@googlegroups.com
Hi,  

I am using ubunutu 12.04 server edition.  

R does start from the command line, but i can not successfully run the png() function.  I get the 

Error in X11(paste("png:::", filename, sep = ""), g$width, g$height, pointsize, : 
    unable to start device PNG
In addition: warning message: 
In png() : no png support in this version of R.


It looks like I have not properly compiled R.  I could not use the directions in the tutorial for installing R because those directions now install  R 3.0.0 

I tried to compile with the following code 

sudo cd /usr/local
sudo mkdir R
sudo tar zxvf r-base_2.15.3.orig.tar.gz
cd R-2.15.3/
sudo apt-get install tk-dev gcc gfortran texlive texlive-fonts-extra libreadline-dev xorg-dev libxml2-dev libcurl4-gnutls-dev
sudo ./configure
sudo make
sudo make check
sudo make install

I must be missing something.  Do i need to remove R and then re-install after adding the relevant packages or is adding the relevant packages at this point sufficient?

thanks,
bobby

Winston Chang

unread,
May 15, 2013, 10:19:32 AM5/15/13
to shiny-...@googlegroups.com
Instead of installing from source, you can install a specific version of R. Change the line in the instructions to:
  sudo apt-get install r-base=2.15.3-1precise0precise1 r-base-dev=2.15.3-1precise0precise1

-Winston

Stéphane Laurent

unread,
Jul 30, 2013, 9:01:36 AM7/30/13
to shiny-...@googlegroups.com
We have the same problem with the Shiny Server in my company.
I hope my colleague (IT specialist) will find a solution tomorrow. 

Winston Chang

unread,
Jul 30, 2013, 11:57:01 AM7/30/13
to shiny-...@googlegroups.com
Have you installed the graphics package? It's usually included by default when you install R, but some methods of installing R don't include it.

-Winston


--

Stéphane Laurent

unread,
Jul 30, 2013, 1:19:53 PM7/30/13
to shiny-...@googlegroups.com
Hello Winston,

 This is surely not a problem with some packages.My colleague has recently done some modifications to allow me to have access to the ShinyServer folder, and before these modifications there was no problem. BTW currently there's no problem when 1) we use his computer, which is directly connected to the Linux server, and 2) when the "shiny admin" (the account he has created for me) is connected.
He think this is related to the DISPLAY variable, and he will have a look at that tomorrow. I will inform you. 

All the best,
Stéphane

Yihui Xie

unread,
Jul 30, 2013, 2:51:19 PM7/30/13
to shiny-...@googlegroups.com
I'm relatively sure R was leading you to the wrong direction, although
your IT specialist is absolutely correct on that wrong direction. See
my answer on SO.

Regards,
Yihui
--
Yihui Xie <xiey...@gmail.com>
Phone: 206-667-4385 Web: http://yihui.name
Fred Hutchinson Cancer Research Center, Seattle


On Tue, Jul 30, 2013 at 10:19 AM, Stéphane Laurent

Stéphane Laurent

unread,
Jul 30, 2013, 3:06:14 PM7/30/13
to shiny-...@googlegroups.com
Hello Yihui. 
I have seen your answer, thank you. We will try tomorrow, I hope.

Stéphane

cka...@csu.fullerton.edu

unread,
Jul 30, 2013, 5:38:36 PM7/30/13
to shiny-...@googlegroups.com
I'm having the same problem on a development server and I'm trying to find an answer.  For right now if I start the shiny server with headless X using 'sudo xvfb-run shiny-server' it works fine.

Stéphane Laurent

unread,
Aug 1, 2013, 8:27:38 AM8/1/13
to shiny-...@googlegroups.com
Hi everybody,

We have switched back to R-2.15 and everything works well.  Do you have an idea about what should we do in order to use R-3.0.1 ? 
Message has been deleted

Stéphane Laurent

unread,
Aug 1, 2013, 1:43:43 PM8/1/13
to shiny-...@googlegroups.com
Sorry, I have just realized that I have not tried the png() function from the command line. Currently I have only noted the problem in the browser :  Error  Unable to start device PNG
I'lll try tomorrow the png() function in R. 

Winston Chang

unread,
Aug 2, 2013, 3:18:10 PM8/2/13
to shiny-...@googlegroups.com
Stephane, we're unable to reproduce the problem on Centos 6.4. Can you send a complete list of packages installed on your system? The command is:
  yum list installed

You can send directly to me and Joe if you don't want to post this information to the list.

-Winston



On Thu, Aug 1, 2013 at 12:43 PM, Stéphane Laurent <lauren...@yahoo.fr> wrote:
Sorry, I have just realized that I have not tried the png() function from the command line. Currently I have only noted the problem in the browser :  Error  Unable to start device PNG
I'lll try tomorrow the png() function in R. 

--

Stéphane Laurent

unread,
Aug 2, 2013, 4:00:51 PM8/2/13
to shiny-...@googlegroups.com
Hello Winston.

To sum up, there were two steps in the solution :
 1) the R-3.0.1 we used had not been compiled with cairo (I don't know exactly what does it mean, I have never used Linux)
 2) Use Yihui's solution given on SO, for instance by typing options(bitmapType='cairo') in the server.R file

Best regards, many thanks for your help,
Stéphane

Yihui Xie

unread,
Aug 2, 2013, 4:32:39 PM8/2/13
to shiny-...@googlegroups.com
Normally I think it is better to use the pre-compiled binaries instead
of ./configure && make from source, because it is likely that you
missed an optional dependency without noticing it. You need to read
the output from ./configure carefully.

I do not use CentOS, but a quick Google search gives me
http://stackoverflow.com/questions/9468164/problems-installing-r-on-linux-centos-6-2

To Winston: if you want to reproduce this problem, you can try to
compile R-devel from source on glimmer (although it is Ubuntu, you
should be able to see the problem of the png() device). Or just try my
build here: /home/yihui/repos/r-source/bin/R It will be great if you
can figure this out, because it has puzzled me for quite a while. My
best guess is pango headers were not installed.

Regards,
Yihui
--
Yihui Xie <xiey...@gmail.com>
Phone: 206-667-4385 Web: http://yihui.name
Fred Hutchinson Cancer Research Center, Seattle


Winston Chang

unread,
Aug 5, 2013, 5:29:30 PM8/5/13
to shiny-...@googlegroups.com
I built R-trunk from source, and get the same error. But png(type="cairo") works fine.

Even though png() has a default of type=c("cairo", "cairo-png", "Xlib", "quartz"), it doesn't actually use "cairo" as the default, because of this line:
 if(missing(type)) type <- getOption("bitmapType")

So it actually uses the value of getOption("bitmapType"). On the normal R installation, this returns:
> getOption("bitmapType")
[1] "cairo"

But on the version built from source:
> getOption("bitmapType")
[1] "Xlib"


Now, it appears that the bitmapType option gets set when grDevices is loaded:

list(bitmapType = if(capabilities("aqua")) "quartz"
else if(.Call(C_cairoProps, 2L)) "cairo" else "Xlib")

For some reason this returns FALSE on my R-trunk built from source:
   .Call(grDevices:::C_cairoProps, 2L) # FALSE
That value is probably not right, considering that I can create PNG graphics just fine with png(type="cairo").

In the installed R 2.15.3 on Glimmer, the corresponding call returns TRUE
   .Call(grDevices:::cairoProps, 2L) # TRUE


And if you dig deeper into the C code, it looks like FALSE value does have something to do with Pango, via HAVE_PANGOCAIRO:

I don't see anywhere in the R source where HAVE_PANGOCAIRO is set to 1, so I'm not really sure what to make of this. Perhaps it's supposed to be set in a header from Pango?


-Winston

Winston Chang

unread,
Aug 5, 2013, 5:44:54 PM8/5/13
to shiny-...@googlegroups.com
Hm, it actually looks like HAVE_PANGOCAIRO is set in the configure script. It _looks_ like it wants this to return true:
  pkg-config --exists pangocairo

... which it does on glimmer. It uses the output of that to set 'r_cv_has_pangocairo'. But it's saying (in config.log) that the value is 'no' for some reason.

Yihui Xie

unread,
Aug 5, 2013, 6:31:04 PM8/5/13
to shiny-...@googlegroups.com
I do not see cairopango on glimmer:

$ pkg-config --list-all | grep cairo
cairo-xcb cairo-xcb - XCB surface backend for cairo graphics library
cairo-gobject cairo-gobject - gobject functions for cairo
graphics library
cairo-ps cairo-ps - PostScript surface backend for cairo
graphics library
cairo-pdf cairo-pdf - PDF surface backend for cairo graphics library
cairo-xlib cairo-xlib - Xlib surface backend for cairo
graphics library
cairo-xcb-shm cairo-xcb-shm - XCB/SHM functions for cairo
graphics library
cairo-fc cairo-fc - Fontconfig font backend for cairo
graphics library
cairo-xlib-xrender cairo-xlib-xrender - Xlib Xrender surface
backend for cairo graphics library
cairo cairo - Multi-platform 2D graphics library
cairo-png cairo-png - PNG functions for cairo graphics library
cairo-ft cairo-ft - FreeType font backend for cairo
graphics library
cairo-svg cairo-svg - SVG surface backend for cairo graphics library

$ pkg-config --list-all | grep pango

Under Ubuntu, it is easy to install the dependencies required for
building a package from source, e.g. for R, you can

sudo apt-get build-dep r-base-dev

I think what is missing on glimmer is libpango1.0-dev, as you will
find out when running apt-get build-dep.

I'm not sure what is the equivalent command for Red Hat, though.
Building R from source is tricky without something like apt-get
build-dep.

Regards,
Yihui
--
Yihui Xie <xiey...@gmail.com>
Phone: 206-667-4385 Web: http://yihui.name
Fred Hutchinson Cancer Research Center, Seattle


Winston Chang

unread,
Aug 5, 2013, 7:08:27 PM8/5/13
to shiny-...@googlegroups.com
On Mon, Aug 5, 2013 at 5:31 PM, Yihui Xie <xiey...@gmail.com> wrote:
I do not see cairopango on glimmer:

$ pkg-config --list-all | grep cairo
cairo-xcb             cairo-xcb - XCB surface backend for cairo graphics library
cairo-gobject         cairo-gobject - gobject functions for cairo
graphics library
cairo-ps              cairo-ps - PostScript surface backend for cairo
graphics library
cairo-pdf             cairo-pdf - PDF surface backend for cairo graphics library
cairo-xlib            cairo-xlib - Xlib surface backend for cairo
graphics library
cairo-xcb-shm         cairo-xcb-shm - XCB/SHM functions for cairo
graphics library
cairo-fc              cairo-fc - Fontconfig font backend for cairo
graphics library
cairo-xlib-xrender    cairo-xlib-xrender - Xlib Xrender surface
backend for cairo graphics library
cairo                 cairo - Multi-platform 2D graphics library
cairo-png             cairo-png - PNG functions for cairo graphics library
cairo-ft              cairo-ft - FreeType font backend for cairo
graphics library
cairo-svg             cairo-svg - SVG surface backend for cairo graphics library

$ pkg-config --list-all | grep pango


Ah, good call. I was doing this:
$ pkg-config --exists pangocairo
$ echo $?

But I thought 1 meant true -- I forgot that in shell scripts, 0 is success and other values are failure.




Under Ubuntu, it is easy to install the dependencies required for
building a package from source, e.g. for R, you can

  sudo apt-get build-dep r-base-dev

I think what is missing on glimmer is libpango1.0-dev, as you will
find out when running apt-get build-dep.

It looks like we had run `sudo apt-get build-dep r-base`, but that was several months ago, and it must not have included libpango1.0-dev back then.

Yes, it appears that installing pango and re-running configure and make does the trick. On Ubuntu:
  apt-get install libpango1.0-dev

So now building R-trunk in Glimmer/Spark should result in png() just working.


I'm not sure what is the equivalent command for Red Hat, though.
Building R from source is tricky without something like apt-get
build-dep.


Thanks!
-Winston
 

 

Yihui Xie

unread,
Aug 5, 2013, 7:45:05 PM8/5/13
to shiny-...@googlegroups.com
Great. Yes, I believe they added this .Call(C_cairoProps, 2L) recently
(perhaps a few months ago), because I have never met this problem
before. Anyway, I'm glad this has been figured out.

Regards,
Yihui
--
Yihui Xie <xiey...@gmail.com>
Phone: 206-667-4385 Web: http://yihui.name
Fred Hutchinson Cancer Research Center, Seattle


Reply all
Reply to author
Forward
0 new messages