• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

centos7下为Rstudio安装多版本R

武飞扬头像
yummy2009
帮助1

之前的R版本太旧,不少包装不上,需要安装新版本的R:

  1.  
    R --version
  2.  
    R version 3.6.0 (2019-04-26) -- "Planting of a Tree"

于是下载最新版R:

因为没有证书,需要加上最后面的参数.

wget https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/base/R-4/R-4.2.2.tar.gz --no-check-certificate

或者使用 

yum install -y ca-certificates

第一次配制报错:

  1.  
    ./configure --enable-R-shlib --prefix=/opt/R/R-4.2.2 --with-x=no
  2.  
    ...
  3.  
    checking for readline/history.h... no
  4.  
    checking for readline/readline.h... no
  5.  
    checking for rl_callback_read_char in -lreadline... no
  6.  
    checking for main in -lncurses... no
  7.  
    checking for main in -ltinfo... no
  8.  
    checking for main in -ltermcap... no
  9.  
    checking for main in -ltermlib... no
  10.  
    checking for rl_callback_read_char in -lreadline... no
  11.  
    configure: error: --with-readline=yes (default) and headers/libs are not available

这是因为没有装readline这个包:

  1.  
    sudo yum install readline-devel
  2.  
    ...
  3.  
    Running transaction
  4.  
    Installing : ncurses-devel-5.9-14.20130511.el7_4.x86_64 1/2
  5.  
    Installing : readline-devel-6.2-11.el7.x86_64 2/2
  6.  
    Verifying : readline-devel-6.2-11.el7.x86_64 1/2
  7.  
    Verifying : ncurses-devel-5.9-14.20130511.el7_4.x86_64 2/2
  8.  
     
  9.  
    Installed:
  10.  
    readline-devel.x86_64 0:6.2-11.el7
  11.  
     
  12.  
    Dependency Installed:
  13.  
    ncurses-devel.x86_64 0:5.9-14.20130511.el7_4
  14.  
     
  15.  
    Complete!
学新通

然后继续配置:

  1.  
    ./configure --enable-R-shlib --prefix=/opt/R/R-4.2.2 --with-x=no --with-readline=yes --with-libpng=yes --with-blas
  2.  
    ...
  3.  
    R is now configured for x86_64-pc-linux-gnu
  4.  
     
  5.  
    Source directory: .
  6.  
    Installation directory: /opt/R/R-4.2.2
  7.  
     
  8.  
    C compiler: gcc -std=gnu11 -g -O2
  9.  
    Fortran fixed-form compiler: gfortran -g -O2
  10.  
     
  11.  
    Default C compiler: g -std=gnu 11 -g -O2
  12.  
    C 11 compiler: g -std=gnu 11 -g -O2
  13.  
    C 14 compiler:
  14.  
    C 17 compiler:
  15.  
    C 20 compiler:
  16.  
    Fortran free-form compiler: gfortran -g -O2
  17.  
    Obj-C compiler:
  18.  
     
  19.  
    Interfaces supported: tcltk
  20.  
    External libraries: pcre2, readline, curl
  21.  
    Additional capabilities: PNG, JPEG, TIFF, NLS, ICU
  22.  
    Options enabled: shared R library, shared BLAS, R profiling
  23.  
     
  24.  
    Capabilities skipped: cairo
  25.  
    Options not enabled: memory profiling
  26.  
     
  27.  
    Recommended packages: yes
  28.  
     
  29.  
    configure: WARNING: neither inconsolata.sty nor zi4.sty found: PDF vignettes and package manuals will not be rendered optimally
学新通

最后一段警告信息让人不爽. 这是latex的sty包没装,于是装一下:

  1.  
    wget http://mirrors.ctan.org/fonts/inconsolata.zip
  2.  
     
  3.  
    unzip inconsolata.zip
  4.  
    Archive: inconsolata.zip
  5.  
    creating: inconsolata/
  6.  
    ...
  7.  
    inflating: inconsolata/tex/inconsolata.sty
  8.  
    ...
  9.  
     
  10.  
    cp -R inconsolata/* /usr/share/texmf/
  11.  
     
  12.  
    sudo yum install texlive
  13.  
     
  14.  
    sudo texhash
  15.  
    texhash: Updating /usr/share/texlive/texmf/ls-R...
  16.  
    texhash: Updating /usr/share/texlive/texmf-config/ls-R...
  17.  
    texhash: Updating /usr/share/texlive/texmf-dist/ls-R...
  18.  
    texhash: Updating /usr/share/texlive/texmf-local///ls-R...
  19.  
    texhash: Updating /usr/share/texlive/texmf-var/ls-R...
  20.  
    texhash: Done.
  21.  
     
学新通

然后再配置就不会有警告信息了:

  1.  
    ./configure --enable-R-shlib --prefix=/opt/R/R-4.2.2 --with-x=no --with-readline=yes --with-libpng=yes --with-blas
  2.  
    ...
  3.  
    R is now configured for x86_64-pc-linux-gnu
  4.  
     
  5.  
    Source directory: .
  6.  
    Installation directory: /opt/R/R-4.2.2
  7.  
     
  8.  
    C compiler: gcc -std=gnu11 -g -O2
  9.  
    Fortran fixed-form compiler: gfortran -g -O2
  10.  
     
  11.  
    Default C compiler: g -std=gnu 11 -g -O2
  12.  
    C 11 compiler: g -std=gnu 11 -g -O2
  13.  
    C 14 compiler:
  14.  
    C 17 compiler:
  15.  
    C 20 compiler:
  16.  
    Fortran free-form compiler: gfortran -g -O2
  17.  
    Obj-C compiler:
  18.  
     
  19.  
    Interfaces supported: tcltk
  20.  
    External libraries: pcre2, readline, curl
  21.  
    Additional capabilities: PNG, JPEG, TIFF, NLS, ICU
  22.  
    Options enabled: shared R library, shared BLAS, R profiling
  23.  
     
  24.  
    Capabilities skipped: cairo
  25.  
    Options not enabled: memory profiling
  26.  
     
  27.  
    Recommended packages: yes
学新通

configuare 参数说明:

–enable-R-shlib 表示生成libR.so库,当需要进行gcc等编译的时候很重要,确保之后安装R-studio-server时会出现 找不到"lib.so"文件的错误。

–with-readline=yes表示用于R shell条件下的调试优化

–with-libpng=yes表示可导出png图片

–with-blas表示优化R运算并生成libRblas.so库

–prefix 设定安装路径,否则make install会去安装到/usr/lib文件夹下,非root用户没有权限.

然后再

  1.  
    make
  2.  
    make install

最后将R指向新装的R

  1.  
    which R
  2.  
    sudo mv /usr/bin/R /usr/bin/R.3.6
  3.  
    ln -s /opt/R/R-4.2.2/bin/R /usr/bin/R
  4.  
    R
  5.  
     
  6.  
    R version 4.2.2 (2022-10-31) -- "Innocent and Trusting"
  7.  
    Copyright (C) 2022 The R Foundation for Statistical Computing
  8.  
    Platform: x86_64-pc-linux-gnu (64-bit)

Innocent and Trusting...ok....重启Rstudio...

学新通

但悲剧还没结束, Rstudio版本太旧, 不匹配R4.2.2里的图形引擎:

学新通

学新通

最后的解决方案是退回到4.0.2:

学新通

ref:

Ubntu 14.04 LTS 下编译安装R Source Code_Linux教程_Linux公社-Linux系统门户网站

全网最全:新处理器安装R所出现的报错问题 - 简书

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhggkbch
系列文章
更多 icon
同类精品
更多 icon
继续加载