[R]CentOS7下安裝R

Allen
NoteOcean
Published in
4 min readFeb 24, 2021

在伺服器中安裝R,但遇到了很多很多問題,故寫這篇作為筆記。

在ubuntu中,通常只要會下載tar.gz檔,就可以安心的使用R了,但是在CentOS卻會遇到很多套件沒有安裝,而無法安裝R。以下開始那簡述這些ERROR。

首先是下載並解壓縮R的部份--這裡沒有ERROR~~~

wget https://mirrors.aliyun.com/CRAN/src/base/R-3/R-3.4.4.tar.gz

tar zxvf R-3.5.0.tar.gz

cd R-3.5.0

一、要做./configure — prefix=/usr/local/R-3.5.0 — enable-R-shlib

就會遇到:

gcc-gfortran #错误信息:“configure: error: No F77 compiler found”

gcc gcc-c++ #错误信息:“configure: error: C++ preprocessor “/lib/cpp” fails sanity check”

readline-devel #错误信息:“–with-readline=yes (default) and headers/libs are not available”

libXt-devel #错误信息:“configure: error: –with-x=yes (default) and X11 headers/libs are not available”

解決:

yum install -y gcc gcc-c++ gcc-gfortran libXt-devel readline-devel binutils

二、ERROR:

checking whether bzip2 support suffices… configure: error: bzip2 library and headers are required

解決:

yum install -y zlib-devel bzip2-devel

三、ERROR:

configure: error: “liblzma library and headers are required”

解決:

yum install -y xz-devel

四、ERROR:

whether PCRE support suffices… configure: error: pcre >= 8.20 library and headers are required

解決:

yum install -y pcre-devel

五、ERROR:

checking for curl-config… no

checking curl/curl.h usability… no

checking curl/curl.h presence… no

checking for curl/curl.h… no

configure: error: libcurl >= 7.22.0 library and headers are required with support for https

解決:

# 1.下载解壓安装

wget https://curl.haxx.se/download/curl-7.57.0.tar.gz

tar zxvf curl-7.57.0.tar.gz

cd curl-7.57.0

./configure — prefix=/opt/curl-7.57.0

make && make install

#2.在/etc/proflie添加以下環境變數(重要):

export PATH=/opt/curl-7.57.0/bin

#3.使環境變數生效:

source /etc/profile

#4验证

curl –version

# 會跑出 :curl 7.57.0 (x86_64-pc-linux-gnu) libcurl/7.57.0 OpenSSL/1.0.2k zlib/1.2.7

再來就可以開心的:

/configure — prefix=/usr/local/R-3.5.0 — enable-R-shlib

make & make install

記得將R BIN新增到環境變數裡 之後就可以正常使用了。

--

--