无法安装R包:"非零退出状态" (除非是sudo)

时间:2018-03-28 05:35:25

标签: r ubuntu anaconda

奇怪的行为:在此之前,我已经能够使用R studio等安装R包,特别是使用install.packages("<package name>")。现在,除非我在终端窗口中直接使用sudo运行R,否则我无法在不接收以下回溯的情况下安装包:

> install.packages("mlbench")
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://mirrors.sorengard.com/cran/src/contrib/mlbench_2.1-1.tar.gz'
Content type 'application/x-gzip' length 920768 bytes (899 KB)
==================================================
downloaded 899 KB

* installing *source* package ‘mlbench’ ...
** package ‘mlbench’ successfully unpacked and MD5 sums checked
** libs
/home/alex/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -I/home/alex/anaconda3/lib/R/include -DNDEBUG   -D_FORTIFY_SOURCE=2 -O2 -I/home/alex/anaconda3/include   -fpic  -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -I/home/alex/anaconda3/include  -c waveform.c -o waveform.o
make: /home/alex/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc: Command not found
/home/alex/anaconda3/lib/R/etc/Makeconf:160: recipe for target 'waveform.o' failed
make: *** [waveform.o] Error 127
ERROR: compilation failed for package ‘mlbench’
* removing ‘/home/alex/anaconda3/lib/R/library/mlbench’
* restoring previous ‘/home/alex/anaconda3/lib/R/library/mlbench’

The downloaded source packages are in
        ‘/tmp/RtmpRBWDWi/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("mlbench") :
  installation of package ‘mlbench’ had non-zero exit status

我尝试了很多这种情况,但mlbench是我现在最关心的问题。

非常感谢任何帮助。

R(带anaconda)
Kubuntu 17.10(Artful)

1 个答案:

答案 0 :(得分:0)

由@ r2evans在评论中发布,link提供了适用于我的提示。

因为我使用anaconda来管理我的R环境,所以这就解决了我遇到的问题:conda install gxx_linux-64

同时

如果您看到类似的错误,但回溯线类似于make: /home/alex/anaconda3/bin/x86_64-conda_cos6-linux-gnu-gfortran: Command not found...,请使用终端运行与上面相同的行,但指定gfortran而不是gcc:{{ 1}}。