我在Centos服务器上安装了R 3.3.0。我安装了多个软件包,包括闪亮和进一步安装的闪亮服务器我已经加载了我的应用程序文件,应用程序正在运行我有一些ggplot没有呈现,我收到一条错误消息:
X11 is not available
我用Google搜索并执行了以下操作:
在R控制台中运行capabilities()后,我得到以下内容:
jpeg png tiff tcltk X11 aqua
FALSE FALSE FALSE FALSE FALSE FALSE
http/ftp sockets libxml fifo cledit iconv
TRUE TRUE TRUE TRUE FALSE TRUE
NLS profmem cairo ICU long.double libcurl
TRUE FALSE FALSE FALSE TRUE TRUE
我安装了:
yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"
yum install cairo-devel
yum install libXt-devel
install.packages("Cairo")
yum install xorg-x11-xauth
yum install xorg-x11-apps
以上所有内容都已安装,但即使加载了库(开罗)后我仍然遇到同样的错误。
当我在R中运行Sys.getenv("DISPLAY")
时,我得到一个空白""
其中一个解决方案here表示我应该使用./configure --with-x=no
重新编译R.而另一篇博客here表明我不应该这样做的原因。我想知道的是:
yum install r-base-dev./configure --with-x=no
帮助?答案 0 :(得分:2)
虽然这是一个老问题,当你谷歌它有一些解决方法,我发现一篇关于从源代码构建R的帖子,这使得这个过程更容易。
您需要在此帖子中运行的命令可以汇总为
yum install epel-release
yum install yum-utils # to make yum-builddep command available
yum-builddep R # this command will install all the dependencies for building R from source
# Then under your R source folder run (I'm using R version 3.2.3, so you will want to change the version number in these commands):
./configure --prefix=/opt/R/3.2.3 --enable-R-shlib --with-blas --with-lapack # you can substitute your own target directory for /opt/R/3.2.3
make
make install
这将成功在您的CentOS机器上安装R.但是,您可以手动安装这些库,而不是使用yum-builddep为您安装依赖库,因此您可以跳过已有的库。
如果您重新运行yum-builddep R
,您将获得所有安装的依赖项,它们是:
--> Already installed : zlib-devel-1.2.7-17.el7.x86_64
--> Already installed : xz-devel-5.2.2-1.el7.x86_64
--> Already installed : 1:valgrind-devel-3.11.0-24.el7.x86_64
--> Already installed : tre-devel-0.8.0-18.20140228gitc2f5d13.el7.x86_64
--> Already installed : 1:tk-devel-8.5.13-6.el7.x86_64
--> Already installed : texinfo-tex-5.1-4.el7.x86_64
--> Already installed : 2:texlive-collection-latexrecommended-svn25795.0-38.20130427_r30134.el7.noarch
--> Already installed : 1:tcl-devel-8.5.13-8.el7.x86_64
--> Already installed : readline-devel-6.2-9.el7.x86_64
--> Already installed : pcre-devel-8.32-15.el7_2.1.x86_64
--> Already installed : pango-devel-1.36.8-2.el7.x86_64
--> Already installed : openblas-devel-0.2.19-4.el7.x86_64
--> Already installed : ncurses-devel-5.9-13.20130511.el7.x86_64
--> Already installed : libtool-2.4.2-22.el7_3.x86_64
--> Already installed : libtiff-devel-4.0.3-27.el7_3.x86_64
--> Already installed : 2:libpng-devel-1.5.13-7.el7_2.x86_64
--> Already installed : libjpeg-turbo-devel-1.2.90-5.el7.x86_64
--> Already installed : libicu-devel-50.1.2-15.el7.x86_64
--> Already installed : libcurl-devel-7.29.0-35.el7.centos.x86_64
--> Already installed : libXt-devel-1.1.4-6.1.el7.x86_64
--> Already installed : libXmu-devel-1.1.2-2.el7.x86_64
--> Already installed : libX11-devel-1.6.3-3.el7.x86_64
--> Already installed : libSM-devel-1.2.2-2.el7.x86_64
--> Already installed : libICE-devel-1.0.9-2.el7.x86_64
--> Already installed : less-458-9.el7.x86_64
--> Already installed : 1:java-1.8.0-openjdk-headless-1.8.0.131-2.b11.el7_3.x86_64
--> Already installed : gcc-objc-4.8.5-11.el7.x86_64
--> Already installed : gcc-gfortran-4.8.5-11.el7.x86_64
--> Already installed : gcc-c++-4.8.5-11.el7.x86_64
--> Already installed : cairo-devel-1.14.2-1.el7.x86_64
--> Already installed : bzip2-devel-1.0.6-13.el7.x86_64
--> Already installed : automake-1.13.4-3.el7.noarch
--> Already installed : autoconf-2.69-11.el7.noarch
因此,如果您已经安装了“开发工具”或其他一些软件包,您可以选择根据当前库安装其中一些库。
在我的情况下,我安装了Oracle JDK,所以我不需要yum-builddep安装open-jdk,所以当我正确设置JAVA_HOME时,我删除了open-jdk并且编译没有任何错误。
答案 1 :(得分:0)
即使在系统上安装了X11,我仍然遇到了让它运行的问题。确保还安装了Cairo。请注意,这是假设如果在终端中打开R并键入x11(),则不再出现“X11不可用错误”。
可以使用以下命令进行测试(感谢https://github.com/IRkernel/IRkernel/issues/388)
库(数据集) png(“test.png”,width = 1200,height = 1200,units =“px”,type =“cairo”) boxplot(mpg~cys,data = mtcars,main =“Car Milage Data”,xlab =“Cylinders数量”,ylab =“每加仑英里数”) dev.off()