I'm running R 2.9 on a large EC2 Ubuntu instance, loaded with RAM, but without a terminal. When I load a library that has display dependencies, such as the sqldf package, I receive the following error:
我正在一个大型的EC2 Ubuntu实例上运行r2.9,它装载了RAM,但是没有终端。当我加载具有显示依赖项的库(如sqldf包)时,我将收到以下错误:
library(sqldf)
...
Loading required package: tcltk
Loading Tcl/Tk interface ... Error in fun(...) : couldn't connect to display "localhost:11.0"
Error : .onLoad failed in 'loadNamespace' for 'tcltk'
Error: package 'tcltk' could not be loaded
This seems to be a general problem, and I'm wondering how others have solved it. Installing an X11 server is not a desirable solution.
这似乎是一个普遍的问题,我想知道其他人是怎么解决的。安装X11服务器不是理想的解决方案。
2 个解决方案
#1
32
Use the virtual framebuffer X11 server -- we do the same to build packages requiring X11 for R builds in headless chroots. Taking e.g. pars of the Build-Depends from rggobi
:
使用虚拟的framebuffer X11服务器——我们同样构建需要X11的包,以便在无头的chroot中构建R。例如,建筑物的部分-依赖于rggobi:
xvfb xauth xfonts-base
xvfb xauth xfonts-base
After installing these you can use the xvfb-run
command. If you start R via e.g.
在安装这些文件之后,您可以使用xvfb-run命令。如果你从R开始。
xvfb-run R --no-save
you should now be able to use routines and commands requiring X11 as e.g. some of the plotting devices, or the tcl/tk initialization which also insists on having X11.
您现在应该能够使用需要X11的例程和命令,例如一些绘图设备,或者tcl/tk初始化,它也坚持使用X11。
The same trick is useful for web servers.
同样的技巧对web服务器也很有用。
#2
9
Dirk's suggestion indeed works well, if you have control over the server & can run xvfb. If not, read on...
如果你控制了服务器,并且可以运行xvfb,那么德克的建议确实有效。如果不是,请继续阅读…
in newer versions of R (>= 2.10 & maybe earlier), this is no longer an error, it's a warning:
在更新版本的R(>= 2.10或更早版本)中,这不再是一个错误,而是一个警告:
> library(tcltk)
Loading Tcl/Tk interface ... done
Warning message:
In fun(libname, pkgname) : no DISPLAY variable so Tk is not available
You can now suppress this warning, and the subsequent package loading message via:
您现在可以抑制此警告,并通过以下方式加载消息:
> suppressPackageStartupMessages(suppressWarnings(library(tcltk)))
Often you will see this message due to loading a package like qvalue
which depends on tcltk
; if you're after silent operation, you should silently load tcltk first, then the package of interest:
由于加载依赖于tcltk的qvalue这样的包,您经常会看到这条消息;如果您是在静音操作之后,您应该先静音加载tcltk,然后是感兴趣的包:
> suppressPackageStartupMessages(suppressWarnings(library(tcltk)))
> library(qvalue)
Mark
马克
resurrected due to: http://dev.list.galaxyproject.org/wrapping-qvalue-in-Galaxy-td4655164.html
由于复活:http://dev.list.galaxyproject.org/wrapping-qvalue-in-Galaxy-td4655164.html
#1
32
Use the virtual framebuffer X11 server -- we do the same to build packages requiring X11 for R builds in headless chroots. Taking e.g. pars of the Build-Depends from rggobi
:
使用虚拟的framebuffer X11服务器——我们同样构建需要X11的包,以便在无头的chroot中构建R。例如,建筑物的部分-依赖于rggobi:
xvfb xauth xfonts-base
xvfb xauth xfonts-base
After installing these you can use the xvfb-run
command. If you start R via e.g.
在安装这些文件之后,您可以使用xvfb-run命令。如果你从R开始。
xvfb-run R --no-save
you should now be able to use routines and commands requiring X11 as e.g. some of the plotting devices, or the tcl/tk initialization which also insists on having X11.
您现在应该能够使用需要X11的例程和命令,例如一些绘图设备,或者tcl/tk初始化,它也坚持使用X11。
The same trick is useful for web servers.
同样的技巧对web服务器也很有用。
#2
9
Dirk's suggestion indeed works well, if you have control over the server & can run xvfb. If not, read on...
如果你控制了服务器,并且可以运行xvfb,那么德克的建议确实有效。如果不是,请继续阅读…
in newer versions of R (>= 2.10 & maybe earlier), this is no longer an error, it's a warning:
在更新版本的R(>= 2.10或更早版本)中,这不再是一个错误,而是一个警告:
> library(tcltk)
Loading Tcl/Tk interface ... done
Warning message:
In fun(libname, pkgname) : no DISPLAY variable so Tk is not available
You can now suppress this warning, and the subsequent package loading message via:
您现在可以抑制此警告,并通过以下方式加载消息:
> suppressPackageStartupMessages(suppressWarnings(library(tcltk)))
Often you will see this message due to loading a package like qvalue
which depends on tcltk
; if you're after silent operation, you should silently load tcltk first, then the package of interest:
由于加载依赖于tcltk的qvalue这样的包,您经常会看到这条消息;如果您是在静音操作之后,您应该先静音加载tcltk,然后是感兴趣的包:
> suppressPackageStartupMessages(suppressWarnings(library(tcltk)))
> library(qvalue)
Mark
马克
resurrected due to: http://dev.list.galaxyproject.org/wrapping-qvalue-in-Galaxy-td4655164.html
由于复活:http://dev.list.galaxyproject.org/wrapping-qvalue-in-Galaxy-td4655164.html