云网牛站
所在位置:首页 > Linux教程 > 在Ubuntu系统下安装R 3.5.1语言与Rsudio 1.1.456

在Ubuntu系统下安装R 3.5.1语言与Rsudio 1.1.456

2018-10-09 11:51:58作者:Yeyuntian稿源:linux站

本文介绍在Ubuntu操作系统下安装R 3.5.1语言和安装Rstudio 1.1.456作为开发环境,在安装R 3.5.1语言中遇到众多的错误,附解决方案。

 

一、首先是安装R 3.5.1语言

1.下载R-3.5.1.tar.gz

先到CRAN清华大学的镜像中下载R语言的镜像,可以通过apt-get进行安装,但是我们不使用这个方案,因此版本落后了,而现在要安装的版本是R-3.5.1,是目前最新的版本:

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/R$ wget -c https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/base/R-3/R-3.5.1.tar.gz

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/R$ tar zxvf R-3.5.1.tar.gz 

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/R$ cd R-3.5.1/

2.然后进行编译

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/R/R-3.5.1$ ./configure --enable-R-shlib=yes 

checking build system type... x86_64-pc-linux-gnu

checking host system type... x86_64-pc-linux-gnu

loading site script './config.site'

loading build-specific script './config.site'

.......

.....

...

..

.

checking for cf77... no

checking for fort77... no

checking for fl32... no

checking for af77... no

checking for fc... no

configure: error: No F77 compiler found

3.在这个地方,发现有一个错误,查证后说要安装fortran77:

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/R/R-3.5.0$ sudo apt-get install fort77

4.安装好了过后试一试configure,但是又出现一个问题:

checking for rl_callback_read_char in -lreadline... no

checking for main in -lncurses... 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

5.进一步安装这个就可以继续:

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/R/R-3.5.0$ sudo apt-get install xorg-dev 

6.接下来又会遇到的问题是:

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

这个问题的解决方式是:

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/R/R-3.5.0$ sudo apt-get install libcurl4-gnutls-dev

7.最后遇到一个Warning

R is now configured for x86_64-pc-linux-gnu

Source directory:          .

Installation directory:    /usr/local

C compiler:                gcc  -g -O2

Fortran 77 compiler:       f95  -g -O2

Default C++ compiler:      g++   -g -O2

C++98 compiler:            g++ -std=gnu++98 -g -O2

C++11 compiler:            g++ -std=gnu++11 -g -O2

C++14 compiler:            g++ -std=gnu++14 -g -O2

C++17 compiler:              

Fortran 90/95 compiler:    gfortran -g -O2

Obj-C compiler:         

Interfaces supported:      X11

External libraries:        readline, curl

Additional capabilities:   PNG, JPEG, NLS

Options enabled:           shared BLAS, R profiling

Capabilities skipped:      TIFF, cairo, ICU

Options not enabled:       memory profiling

Recommended packages:      yes

configure: WARNING: you cannot build info or HTML versions of the R manuals

修复的方法是:

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/R/R-3.5.0$ sudo apt-get install texinfo

8.最后一次编译的结果是:

R is now configured for x86_64-pc-linux-gnu

Source directory:          .

Installation directory:    /usr/local

C compiler:                gcc  -g -O2

Fortran 77 compiler:       f95  -g -O2

Default C++ compiler:      g++   -g -O2

C++98 compiler:            g++ -std=gnu++98 -g -O2

C++11 compiler:            g++ -std=gnu++11 -g -O2

C++14 compiler:            g++ -std=gnu++14 -g -O2

C++17 compiler:              

Fortran 90/95 compiler:    gfortran -g -O2

Obj-C compiler:         

Interfaces supported:      X11

External libraries:        readline, curl

Additional capabilities:   PNG, JPEG, NLS

Options enabled:           shared BLAS, R profiling

Capabilities skipped:      TIFF, cairo, ICU

Options not enabled:       memory profiling

Recommended packages:      yes

9.这样就好了,继续往下走:

trying to compile and link a JNI program 

detected JNI cpp flags    : 

detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm

make[2]: Entering directory '/tmp/Rjavareconf.lrg0CW'

gcc -I"/home/yeyuntian/Software/R/R-3.5.0/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2  -c conftest.c -o conftest.o

conftest.c:1:17: fatal error: jni.h: No such file or directory

compilation terminated.

/home/yeyuntian/Software/R/R-3.5.0/etc/Makeconf:159: recipe for target 'conftest.o' failed

make[2]: *** [conftest.o] Error 1

make[2]: Leaving directory '/tmp/Rjavareconf.lrg0CW'

Unable to compile a JNI program

JAVA_HOME        : /usr/lib/jvm/java-8-openjdk-amd64/jre

Java library path: 

JNI cpp flags    : 

JNI linker flags : 

Updating Java configuration in /home/yeyuntian/Software/R/R-3.5.0

Done.

make[1]: Leaving directory '/home/yeyuntian/Software/R/R-3.5.0'

解决方法是更新安装jdk:

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/R/R-3.5.0$ sudo apt-get install openjdk-8-*

10.然后make好了:

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/R/R-3.5.0$ make check

11.以上步骤没有报错,但是在 make install 的时候就出现以下的问题了:

make: *** [install] Error 1

往上拉看看,有一个报错:

mkdir -p -- /usr/local/lib/R/doc

mkdir: cannot create directory ‘/usr/local/lib/R/doc’: Permission denied

Makefile:104: recipe for target 'installdirs' failed

12.这个报错是因为权限不够,我们加了一个权限试一试:

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/R/R-3.5.0$ sudo make install

OK,问题解决了:

R version 3.5.1

Copyright (C) 2018 The R Foundation for Statistical Computing

Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.

You are welcome to redistribute it under certain conditions.

Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.

Type 'contributors()' for more information and

'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or

'help.start()' for an HTML browser interface to help.

Type 'q()' to quit R.

> q()

Save workspace image? [y/n/c]: y

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/R$ which R

/usr/local/bin/R

注:最后查验了以下,没有问题,因此我们就可以进一步进行我们的Rstudio的安装。

 

二、Rstudio 1.1.456的安装

我们在前面已经安装了R语言,接下来我们来安装Rstudio。

1.先去Rstudio网址去下载对应的Rstudio版本:

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software$ mkdir Rstudio

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software$ l

code_1.27.2-1536736588_amd64.deb  shadowsocksr-linux-client-CLI/    zotero/

R/                                sogoupinyin_2.2.0.0108_amd64.deb

Rstudio/                          texlive/

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software$ cd Rstudio/

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/Rstudio$ k

]k: command not found

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/Rstudio$ l

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/Rstudio$ wget -c https://download1.rstudio.org/rstudio-xenial-1.1.456-amd64.deb

--2018-10-09 10:46:50--  https://download1.rstudio.org/rstudio-xenial-1.1.456-amd64.deb

Connecting to 127.0.0.1:8118... connected.

Proxy request sent, awaiting response... 200 OK

Length: 68100044 (65M) [application/x-deb]

Saving to: ‘rstudio-xenial-1.1.456-amd64.deb’

2.然后进行安装

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/Rstudio$ sudo dpkg -i rstudio-xenial-1.1.456-amd64.deb 

3.遇到了一个依赖问题

dpkg: dependency problems prevent configuration of rstudio:

rstudio depends on libjpeg62; however:

Package libjpeg62 is not installed.

通过apt-get -f来解决:

yeyuntian@yeyuntian-RESCUER-R720-15IKBN:~/Software/Rstudio$ sudo apt-get install -f

4.然后再进行一次dpkg的安装即可。

最后的效果图:

在Ubuntu系统下安装R 3.5.1语言与Rsudio 1.1.456

 

总结

到这里,我们在Ubuntu系统下经过源码编译完成了R 3.5.1语言的安装以及Rstudio 1.1.456的安装,跟着步骤来其实很简单。

 

相关主题

在Ubuntu 18.04系统下源码编译安装Emacs 26.1

精选文章
热门文章