在 Linux Mint 17 上运行 R 3.1.2,当我尝试安装流行的软件包时,我得到一个非零退出状态
。示例 install.packages
尝试的完整输出如下:
> install.packages("plyr")
Installing package into ‘/home/joe_kendrick/R/x86_64-pc-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/plyr_1.8.1.tar.gz'
Content type 'application/x-gzip' length 393233 bytes (384 Kb)
opened URL
==================================================
downloaded 384 Kb
* installing *source* package ‘plyr’ ...
** package ‘plyr’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/share/R/include -DNDEBUG -I"/usr/lib/R/site-library/Rcpp/include" -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
/bin/bash: g++: command not found
make: *** [RcppExports.o] Error 127
ERROR: compilation failed for package ‘plyr’
* removing ‘/home/joe_kendrick/R/x86_64-pc-linux-gnu-library/3.1/plyr’
The downloaded source packages are in
‘/tmp/RtmpXe52Mz/downloaded_packages’
Warning message:
In install.packages("plyr") :
installation of package ‘plyr’ had non-zero exit status
对于我尝试安装的其他包,例如 ggplot2
和 vegan
,我得到的消息基本上是相同的,尽管在许多情况下它更冗长,因为它尝试并失败了安装依赖项。
这似乎是一个有点普遍的问题,但其他人似乎也有 outdated software或 insufficient memory .我正在运行 Mint 和 R 的最新稳定版本,并且我有足够的 RAM 和一个交换文件,所以我认为这些都不会导致我的问题。
最佳答案
根据错误信息
/bin/bash: g++: command not found
你需要安装一个C++编译器。我将从以下之一开始:
sudo apt-get install build-essentials # key tools
或
sudo apt-get install r-base-dev # many development tools for R
或者当然
sudo apt-get install r-cran-rcpp # to not install from source
尽管您获得的 Rcpp 可能比您需要的旧。
对于基于 Debian 的系统的用户,有一个列表 r-sig-debian
。
关于linux - 无法在 Linux Mint 17 上安装 R 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26793359/