问题描述
我在大型 EC2 Ubuntu 实例上运行 R 2.9,加载了 RAM,但没有终端.当我加载具有显示依赖项的库(例如 sqldf 包)时,收到以下错误:
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:
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
这似乎是一个普遍的问题,我想知道其他人是如何解决的.安装 X11 服务器不是一个理想的解决方案.
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 服务器——我们用同样的方法在无头 chroot 中构建需要 X11 的包.以例如来自 rggobi
的 Build-Depends 部分:
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
:
xvfb xauth xfonts-base
安装这些后,您可以使用 xvfb-run
命令.如果你通过例如
After installing these you can use the xvfb-run
command. If you start R via e.g.
xvfb-run R --no-save
您现在应该能够使用需要 X11 的例程和命令,例如一些绘图设备,或 tcl/tk 初始化也坚持使用 X11.
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.
同样的技巧对于网络服务器也很有用.
The same trick is useful for web servers.
这篇关于如何在没有 X11 的服务器上运行 R,并避免依赖关系中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!