【问题标题】:Unable to install R library of facebook prophet on CentOS7无法在 CentOS7 上安装 facebook 先知的 R 库
【发布时间】:2020-10-05 21:48:46
【问题描述】:

我正在尝试在 centOS 7 上为 Facebook 的 prophet 安装 R 库。为了便于重现,我提供了 dockerfile 和命令。

FROM centos:7

RUN yum -y install epel-release
RUN yum -y groupinstall "Development Tools"
RUN yum -y install proj

RUN yum -y install udunits2-devel
RUN yum -y install openssl-devel
RUN yum -y install libjpeg-turbo-devel
RUN yum -y install libcurl-devel

RUN yum -y install v8-devel

RUN yum -y install R

要构建 dockerfile,请使用以下命令。

docker build -t test_prophet_installation .

一旦构建完成,我就使用下一个命令运行容器。

docker run -it --entrypoint=/bin/bash test_prophet_installation

现在,我在我的容器中。我尝试使用以下命令安装prophet

su - -c "R -e \"install.packages('prophet', repos='http://cran.rstudio.com/')\""

上面的命令说,prophet 的依赖项之一,即rstan 安装失败。所以我尝试使用以下命令安装“rstan”。

su - -c "R -e \"install.packages('rstan', repos='http://cran.rstudio.com/')\"" 

运行上述命令后,出现以下错误。

Error in .shlib_internal(args) :
  C++14 standard requested but CXX14 is not defined
* removing '/usr/lib64/R/library/rstan'

The downloaded source packages are in
        '/tmp/RtmpsPDQ9G/downloaded_packages'
Updating HTML index of packages in '.Library'
Warning messages:
1: In install.packages("rstan", repos = "http://cran.rstudio.com/") :
  installation of package 'rstan' had non-zero exit status
2: In file.create(f.tg) :
  cannot create file '/usr/share/doc/R-3.6.0/html/packages.html', reason 'No such file or directory'
3: In make.packages.html(.Library) : cannot update HTML package index

我尝试了几乎所有来自 Google 的故障排除来解决上述错误,但仍然没有成功。我想,我没有正确设置一些环境变量。

【问题讨论】:

  • 看来实际问题是 rstan 没有安装。是对的吗?你检查过谁拥有那个文件夹吗?

标签: r docker centos facebook-prophet


【解决方案1】:

这里的问题是,当使用yum groupinstall "Development Tools"时,安装的gcc是4.8.5,因此不支持C++14(如你所见here)。

为了解决这个问题,您需要添加以下内容:

RUN yum -y install centos-release-scl
RUN yum -y install devtoolset-8-gcc*

RUN scl enable devtoolset-8 sh

除此之外,您还必须为 rstan 定义 Makevars。你可以在这里找到解释:https://github.com/stan-dev/rstan/issues/569

我创建了这个 Makevars:

CXX14 = g++ -std=c++1y -Wno-unused-variable -Wno-unused-function -fPIC

并在我的 Dockerfile 中添加了一个副本:

COPY Makevars /root/.R/Makevars

我正在使用以下命令下载软件包:

install.packages('rstan', repos='http://cran.rstudio.com/', dependencies = TRUE)

有些事情仍然没有按预期工作,但这是向前迈出的一步。

编辑: 这种方法不起作用,因为系统一直使用旧的 g++。我最终使用了 docker 镜像centos/devtoolset-7-toolchain-centos7:latest

【讨论】:

    猜你喜欢
    • 2019-01-24
    • 2022-07-23
    • 1970-01-01
    • 1970-01-01
    • 2021-02-28
    • 2021-01-10
    • 2022-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多