无法在我的Linux机器上安装R中的caret包

8

我在尝试在R中安装caret包时遇到以下错误。

     g++: error: /tmp/Rtmp2Tos7n/R.INSTALL2e6e30153a74/nloptr/nlopt-2.4.2/lib/libnlopt_cxx.a: 
No such file or directory make: *** [nloptr.so] Error 1
    
    ERROR: compilation failed for package ‘nloptr’
    * removing ‘/rmt/csfiles/pgrads/mava290/R/x86_64-suse-linux-gnu-library/3.1/nloptr’
    Warning in install.packages :
      installation of package ‘nloptr’ had non-zero exit status
    ERROR: dependency ‘nloptr’ is not available for package ‘lme4’
    * removing ‘/rmt/csfiles/pgrads/mava290/R/x86_64-suse-linux-gnu-library/3.1/lme4’
    Warning in install.packages :
      installation of package ‘lme4’ had non-zero exit status
    ERROR: dependency ‘lme4’ is not available for package ‘pbkrtest’
    * removing ‘/rmt/csfiles/pgrads/mava290/R/x86_64-suse-linux-gnu-library/3.1/pbkrtest’
    Warning in install.packages :
      installation of package ‘pbkrtest’ had non-zero exit status
    ERROR: dependency ‘lme4’ is not available for package ‘BradleyTerry2’
    * removing ‘/rmt/csfiles/pgrads/mava290/R/x86_64-suse-linux-gnu-library/3.1/BradleyTerry2’
    Warning in install.packages :
      installation of package ‘BradleyTerry2’ had non-zero exit status
    ERROR: dependency ‘pbkrtest’ is not available for package ‘car’
    * removing ‘/rmt/csfiles/pgrads/mava290/R/x86_64-suse-linux-gnu-library/3.1/car’
    Warning in install.packages :
      installation of package ‘car’ had non-zero exit status
    ERROR: dependencies ‘car’, ‘BradleyTerry2’ are not available for package ‘caret’
    * removing ‘/rmt/csfiles/pgrads/mava290/R/x86_64-suse-linux-gnu-library/3.1/caret’
    Warning in install.packages :
      installation of package ‘caret’ had non-zero exit status
    
    The downloaded source packages are in
        ‘/tmp/RtmpG9dYqn/downloaded_packages’

我查看了一个类似的问题,与此有关。

在R中安装caret包时出现依赖项问题

解决这个问题的方法是先安装每个依赖项,但它们都有相同的错误消息。例如:

>install.packages('nloptr')

g++: error: /tmp/RtmpgEn54A/R.INSTALL7015350f0d03/nloptr/nlopt-2.4.2/lib/libnlopt_cxx.a: No such file or directory
make: *** [nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/rmt/csfiles/pgrads/mava290/R/x86_64-suse-linux-gnu-library/3.1/nloptr’
Warning in install.packages :
  installation of package ‘nloptr’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpG9dYqn/downloaded_packages’

我也尝试更改repos即:install.packages('caret', repos='http://cran.rstudio.com/'),但它也没有起作用。

我的会话信息如下:

> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-suse-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tools_3.1.2

你是否先安装了nlopt库的头文件? - user3710546
@Pascal:我按照这个网站https://r-forge.r-project.org/R/?group_id=933 给出的方式,使用命令 install.packages("nloptr", repos="http://R-Forge.R-project.org") 进行安装。这样不就足够了吗?我在使用Linux系统。 - Subha Yoganandan
不,如果你没有在Linux系统中安装nlopt库的头文件,那就不行。 - user3710546
在我的机器上(Linux Debian),有一个libnopt-dev包。我相信这就是导致编译失败的原因,你必须在安装R包之前安装它(使用像YaST这样的软件包管理器,而不是R)。 - xraynaud
2
尝试使用sudo apt-get install r-cran-caret命令安装。如果您无法找到其他方法,这可能会为您安装依赖项。 - cory
如果他们正在使用SUSE,apt-get是不起作用的。 - Dason
4个回答

2

我希望先添加一条评论。在2015年1月28日,github上的nloptr包有一个新增内容,可能会导致编译出现问题。我使用了一个解决方法,通过以下命令从旧版本安装:

install.packages("http://cran.r-project.org/src/contrib/Archive/nloptr/nloptr_1.0.0.tar.gz",
                 repos=NULL, type="source")

2

我最近也遇到了nlopt的问题。通过从YaST(或您喜欢的软件包管理器)安装nlopt-devel及其相关依赖项,问题很容易得到解决。


0

-1

我通过首先从synaptic安装"car"(使用带有"cran-car"过滤器)来解决此问题。

然后我使用rstudio安装了"caret",但我想它也适用于R。

希望能有所帮助, 问候


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接