【问题标题】:Not able to install rstanarm on Ubuntu 18.04 LTS无法在 Ubuntu 18.04 LTS 上安装 rstanarm
【发布时间】:2019-04-10 11:42:05
【问题描述】:

我无法在R 3.5.3 上安装rstanarm,在Ubuntu 18.04 LTS 上运行。我使用了以下命令:

install.packages("rstanarm")

devtools::install_github("stan-dev/rstanarm", build_vignettes = FALSE)

两者都抛出以下错误:

Execution halted
Makevars:17: recipe for target 'stan_files/lm.cc' failed
make: *** [stan_files/lm.cc] Error 1
ERROR: compilation failed for package ‘rstanarm’

会话信息

sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

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

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

other attached packages:
[1] usethis_1.5.0  devtools_2.0.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1        ps_1.3.0          prettyunits_1.0.2 rprojroot_1.3-2  
 [5] digest_0.6.18     crayon_1.3.4      withr_2.1.2       assertthat_0.2.1 
 [9] R6_2.4.0          backports_1.1.3   magrittr_1.5      rlang_0.3.4      
[13] cli_1.1.0         curl_3.3          fs_1.2.7          remotes_2.0.2    
[17] testthat_2.0.1    callr_3.2.0       desc_1.2.0        tools_3.5.3      
[21] glue_1.3.1        pkgload_1.0.2     compiler_3.5.3    processx_3.3.0   
[25] pkgbuild_1.0.3    sessioninfo_1.1.1 tcltk_3.5.3       memoise_1.1.0    
> 

【问题讨论】:

  • 你有来自github.com/stan-dev/rstan/wiki/…的所有东西吗?
  • 由于您使用的是较新的 Ubuntu,这不太可能,但值得检查 g++ 版本。
  • 感谢@BenGoodrich 的评论。我已经尝试了所有这些,但仍然无法正常工作。有什么想法吗。谢谢
  • Execution halted字样之前显示什么?
  • @duckmayr: "/usr/lib/R/bin/Rscript" -e "source(file.path('..', 'tools', 'make_cc.R')); make_cc(commandArgs(TRUE))" stan_files/lm.stan Error: (converted from warning) S3 methods 'print.stanfit', 'as.array.stanfit', 'as.matrix.stanfit', 'as.data.frame.stanfit', 'is.array.stanfit', 'dim.stanfit', 'dimnames.stanfit', 'names.stanfit', 'names<-.stanfit', 'pairs.stanfit', 'loo.stanfit' were declared in NAMESPACE but not found

标签: r installation ubuntu-18.04 stan rstanarm


【解决方案1】:

在 Ubuntu 18.04 + R 3.5.3 上,您可以通过以下方式安装 rstanarm

sudo add-apt-repository -y "ppa:marutter/rrutter"
sudo add-apt-repository -y "ppa:marutter/c2d4u3.5"
sudo apt update
sudo apt install r-cran-rstanarm

关于您以前可能遇到问题的一些背景信息:

对于那些使用 R 3.5.x 的用户来说,适用于 Ubuntu 的 RStan 安装指南已经过时了。

Ben Goodrich 在 cmets 中链接到 RStan GitHub Guide to Installing RStan on Linux。他们在那里为 Ubuntu 提供以下建议:

# Add marutter's c2d4u repository, (and rrutter for CRAN builds too)
sudo add-apt-repository -y "ppa:marutter/rrutter"
sudo add-apt-repository -y "ppa:marutter/c2d4u"
sudo apt-get update
sudo apt-get install r-cran-rstan

但是,对于较新版本的 R,您需要改为执行以下操作

# Add marutter's c2d4u repository, (and rrutter for CRAN builds too)
sudo add-apt-repository -y "ppa:marutter/rrutter"
sudo add-apt-repository -y "ppa:marutter/c2d4u3.5"
sudo apt-get update
sudo apt-get install r-cran-rstan

这应该可以在 Ubuntu 18.04 + R 3.5.3 上为您安装 RStan。

【讨论】:

  • 已安装。但是,library(rstanarm) 会抛出以下 Error: package or namespace load failed for ‘rstanarm’ in library.dynam(lib, package, package.lib): shared object ‘rstanarm.so’ not found。请有任何想法。
  • @MYaseen208 从终端(从您的主目录)运行find . -name 00LOCK-rstan* 是否返回任何内容?
  • 没有找到任何东西。
【解决方案2】:

第一次发生此错误并假设您在 R 根目录中有一个 .RProfile,您很可能会在其中找到一行:setwd("~/R"),请继续评论此行并重新启动 @987654324 @并获得一个新会话,然后再次运行:install.packages("rstanarm")你应该可以成功安装rstanarm,安装后不要忘记取消注释setwd("~/R"),出现此错误的原因是rstanarm install脚本假定工作目录是包目录的根目录,当您在 .Rprofile 中调用 setwd() 时,情况并非如此 如果您想尝试一下.. 请删除您使用 PPA 安装的 rstanarm

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-09
    • 1970-01-01
    • 2020-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多