简体   繁体   English

无法在 Linux Mint 17 上安装 R 包

[英]Can't install R packages on Linux Mint 17

Running R 3.1.2 on Linux Mint 17, I get a non-zero exit status when I try to install popular packages.在 Linux Mint 17 上运行 R 3.1.2,当我尝试安装流行的软件包时,我得到一个non-zero exit status The full output of an example install.packages attempt is as follows:示例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

I get essentially the same message for other packages I attempt to install, eg ggplot2 and vegan , though in many cases it is more verbose as it tries and fails to install dependencies.对于我尝试安装的其他软件包,例如ggplot2vegan ,我收到的消息基本上相同,但在许多情况下,它会更加冗长,因为它尝试安装依赖项但失败。

This seems like a somewhat common issue, but others seem to have either outdated software or insufficient memory .这似乎是一个有点普遍的问题,但其他人似乎要么软件过时,要么内存不足 I am running the latest stable release of both Mint and R, and I have plenty of RAM and a swap file, so I don't think either of these are causing my issue.我正在运行 Mint 和 R 的最新稳定版本,并且我有足够的 RAM 和交换文件,所以我认为这两者都不会导致我的问题。

Per the error message根据错误消息

 /bin/bash: g++: command not found

you need to install a C++ compiler.你需要安装一个 C++ 编译器。 I would start with one of these:我将从以下之一开始:

 sudo apt-get install build-essentials        # key tools

or或者

 sudo apt-get install r-base-dev              # many development tools for R

or of course或者当然

 sudo apt-get install r-cran-rcpp             # to not install from source

though the Rcpp you get may be older than the one you need.尽管您获得的 Rcpp 可能比您需要的要旧。

There is a list r-sig-debian for users of Debian-based systems.对于基于 Debian 的系统的用户,有一个列表r-sig-debian

In my case, I am running a fairly new installation of Mint 18, and I was missing certain packages.就我而言,我正在运行一个相当新的 Mint 18 安装,但我缺少某些软件包。 Per the error message in R, I attempted to install "readr", but that wouldn't install because I was missing an underlying package, "libcurl4-openssl-dev".根据 R 中的错​​误消息,我尝试安装“readr”,但无法安装,因为我缺少一个基础包“libcurl4-openssl-dev”。 I apt-got that, then readr install without error, and now my packages for RStudio load as expected.我很容易理解,然后 readr 安装没有错误,现在我的 RStudio 包按预期加载。

You should test which repository here 1 works for your Linux Distro.您应该在此处测试哪个存储库1适用于您的 Linux 发行版。 Try add one by one to your '/etc/apt/sources.list' and run:尝试一一添加到您的“/etc/apt/sources.list”并运行:
sudo apt update sudo apt 更新
sudo apt install r-base sudo apt 安装 r-base
On Linux Mint 18.3 it worked with:在 Linux Mint 18.3 上,它适用于:
deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/ deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/
or或者
deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran40/ deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran40/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM