centos6下为Rstudio安装多版本R
创始人
2024-05-30 04:41:42
0

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

R --version
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

第一次配制报错:

./configure --enable-R-shlib --prefix=/opt/R/R-4.2.2 --with-x=no
...
checking for readline/history.h... no
checking for readline/readline.h... no
checking for rl_callback_read_char in -lreadline... no
checking for main in -lncurses... no
checking for main in -ltinfo... no
checking for main in -ltermcap... no
checking for main in -ltermlib... no
checking for rl_callback_read_char in -lreadline... no
configure: error: --with-readline=yes (default) and headers/libs are not available

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

sudo yum install readline-devel
...
Running transactionInstalling : ncurses-devel-5.9-14.20130511.el7_4.x86_64                   1/2 Installing : readline-devel-6.2-11.el7.x86_64                             2/2 Verifying  : readline-devel-6.2-11.el7.x86_64                             1/2 Verifying  : ncurses-devel-5.9-14.20130511.el7_4.x86_64                   2/2 Installed:readline-devel.x86_64 0:6.2-11.el7                                            Dependency Installed:ncurses-devel.x86_64 0:5.9-14.20130511.el7_4                                  Complete!

然后继续配置:

./configure --enable-R-shlib --prefix=/opt/R/R-4.2.2 --with-x=no  --with-readline=yes --with-libpng=yes --with-blas
...
R is now configured for x86_64-pc-linux-gnuSource directory:            .Installation directory:      /opt/R/R-4.2.2C compiler:                  gcc -std=gnu11  -g -O2Fortran fixed-form compiler: gfortran  -g -O2Default C++ compiler:        g++ -std=gnu++11  -g -O2C++11 compiler:              g++ -std=gnu++11  -g -O2C++14 compiler:                 C++17 compiler:                 C++20 compiler:                 Fortran free-form compiler:  gfortran  -g -O2Obj-C compiler:	        Interfaces supported:        tcltkExternal libraries:          pcre2, readline, curlAdditional capabilities:     PNG, JPEG, TIFF, NLS, ICUOptions enabled:             shared R library, shared BLAS, R profilingCapabilities skipped:        cairoOptions not enabled:         memory profilingRecommended packages:        yesconfigure: WARNING: neither inconsolata.sty nor zi4.sty found: PDF vignettes and package manuals will not be rendered optimally

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

wget http://mirrors.ctan.org/fonts/inconsolata.zipunzip inconsolata.zip
Archive:  inconsolata.zipcreating: inconsolata/...inflating: inconsolata/tex/inconsolata.sty ...cp -R inconsolata/* /usr/share/texmf/sudo yum install texlivesudo texhash
texhash: Updating /usr/share/texlive/texmf/ls-R... 
texhash: Updating /usr/share/texlive/texmf-config/ls-R... 
texhash: Updating /usr/share/texlive/texmf-dist/ls-R... 
texhash: Updating /usr/share/texlive/texmf-local///ls-R... 
texhash: Updating /usr/share/texlive/texmf-var/ls-R... 
texhash: Done.

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

./configure --enable-R-shlib --prefix=/opt/R/R-4.2.2 --with-x=no  --with-readline=yes --with-libpng=yes --with-blas
...
R is now configured for x86_64-pc-linux-gnuSource directory:            .Installation directory:      /opt/R/R-4.2.2C compiler:                  gcc -std=gnu11  -g -O2Fortran fixed-form compiler: gfortran  -g -O2Default C++ compiler:        g++ -std=gnu++11  -g -O2C++11 compiler:              g++ -std=gnu++11  -g -O2C++14 compiler:                 C++17 compiler:                 C++20 compiler:                 Fortran free-form compiler:  gfortran  -g -O2Obj-C compiler:	        Interfaces supported:        tcltkExternal libraries:          pcre2, readline, curlAdditional capabilities:     PNG, JPEG, TIFF, NLS, ICUOptions enabled:             shared R library, shared BLAS, R profilingCapabilities skipped:        cairoOptions not enabled:         memory profilingRecommended 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用户没有权限.

然后再

make
make install

最后将R指向新装的R

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

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

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

 

 

ref:

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

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

linux服务器上装r,linux服务器安装R语言及Rstudio server_weixin_39595085的博客-CSDN博客

相关内容

热门资讯

我的同学-小学四年级写人作文... 我的同学-小学四年级写人作文 篇一我的同学小明我有一个非常好的同学,他的名字叫小明。小明是一个非常聪...
作文 好记性不如烂笔头【通用... 作文 好记性不如烂笔头 篇一好记性不如烂笔头,这是一句古训,意味着记忆力再好也不如写下来的好处。在我...
小学生作文四年级400字假期... 小学生作文四年级400字假期回顾 篇一我的暑假暑假终于来了,我迫不及待地迈入了一个充满欢乐和挑战的假...
美丽的安家沟四年级作文(精选... 美丽的安家沟四年级作文 篇一安家沟是我家乡一个美丽的小村庄,它位于山脚下,四周环绕着郁郁葱葱的树林,...
四年级童话作文(精选6篇) 四年级童话作文 篇一:《小兔子的冒险之旅》从前有一只可爱的小兔子,它叫小白。小白住在一个美丽的森林里...
小家庭大变化四年级作文【经典... 小家庭大变化四年级作文 篇一四年级的我,经历了一次小家庭的大变化。这个变化发生在我上小学的第一年,让...
小小动物园四年级作文【最新6... 小小动物园四年级作文 篇一我的家乡有一个小小动物园,里面有各种各样的动物,每次我去都会看到很多有趣的...
我的乐园四年级下册作文200... 我的乐园四年级下册作文200字 篇一我的乐园我家的后院是我的乐园,这里有我最喜欢的花草和小动物。每天...
春天的小学四年级作文300字... 春天的小学四年级作文300字 篇一:春天里的花海春天是一个美丽的季节,它给大地披上了五彩斑斓的外衣。...
我学会了洗衣服四年级作文(精... 我学会了洗衣服四年级作文 篇一我学会了洗衣服在我四年级的时候,我学会了洗衣服。这是一个令人兴奋又有趣...
我的朋友四年级作文500字【... 我的朋友四年级作文500字 篇一:快乐的小伙伴我有一个非常好的朋友,他叫小明。小明是我的同班同学,也...
写快乐的春节小学作文【最新6... 写快乐的春节小学作文 篇一快乐的春节春节是我最喜欢的节日,因为在这个特别的日子里,我可以和家人一起欢...
管门口的金毛四年级作文【推荐... 管门口的金毛四年级作文 篇一我家门口有一只非常可爱的金毛犬,它是我们的守门员,每天都在门口忠实地守卫...
我的压岁钱小学四年级作文【通... 我的压岁钱小学四年级作文 篇一我的压岁钱春节是我最喜欢的节日,因为我可以收到压岁钱。每年过年的时候,...
致那份友谊小学作文(推荐3篇... 致那份友谊小学作文 篇一友谊的力量亲爱的友谊小学的老师们和同学们:我是一名来自友谊小学的学生,今天我...
为自己喝彩小学生作文【精简6... 为自己喝彩小学生作文 篇一我是一名小学生,每天都在学校度过快乐的时光。我喜欢上学,因为学校给了我很多...
我生病了小学作文【精简6篇】 我生病了小学作文 篇一我生病了前几天,我不知道怎么了,突然感觉身体不舒服。我感到头晕目眩,喉咙痛得像...
新学期新打算小学作文450字... 新学期新打算篇一:我要努力学习新的学期开始了,我制定了新的打算,那就是要努力学习。我相信只有努力学习...
我学会了西红柿炒鸡蛋小学作文... 我学会了西红柿炒鸡蛋小学作文 篇一我学会了西红柿炒鸡蛋上周,我学会了一道简单又美味的菜——西红柿炒鸡...
花朵的小学作文【最新3篇】 花朵的小学作文 篇一花朵的奇妙世界花朵是大自然的美丽礼物,它们以各种各样的颜色和形状装点着我们的环境...