Keras 安装失败,Rstudio RcppTOML 具有非零退出状态

Keras installation failed with Rstudio RcppTOML had non-zero exit status

我正在努力在 Linux Centos 7 上的 Rstudio 版本 2021.09.2 Build 382(R 版本 3.6.0 (2019-04-26))上安装 keras。我收到此错误消息:

ERROR: compilation failed for package ‘RcppTOML’
* removing ‘/usr/lib64/R/library/RcppTOML’
ERROR: dependency ‘RcppTOML’ is not available for package ‘reticulate’
* removing ‘/usr/lib64/R/library/reticulate’
ERROR: dependency ‘reticulate’ is not available for package ‘tfautograph’
* removing ‘/usr/lib64/R/library/tfautograph’
ERROR: dependency ‘reticulate’ is not available for package ‘tfruns’
* removing ‘/usr/lib64/R/library/tfruns’
ERROR: dependencies ‘reticulate’, ‘tfruns’, ‘tfautograph’ are not available for package ‘tensorflow’
* removing ‘/usr/lib64/R/library/tensorflow’
ERROR: dependencies ‘reticulate’, ‘tensorflow’, ‘tfruns’ are not available for package ‘keras’
* removing ‘/usr/lib64/R/library/keras’

我尝试直接从 tar 手动安装,但我仍然有同样的错误。

1: In install.packages("keras") :
  installation of package ‘RcppTOML’ had non-zero exit status
2: In install.packages("keras") :
  installation of package ‘reticulate’ had non-zero exit status
3: In install.packages("keras") :
  installation of package ‘tfautograph’ had non-zero exit status
4: In install.packages("keras") :
  installation of package ‘tfruns’ had non-zero exit status
5: In install.packages("keras") :
  installation of package ‘tensorflow’ had non-zero exit status
6: In install.packages("keras") :
  installation of package ‘keras’ had non-zero exit status

知道如何解决吗? 谢谢

我终于明白了,CentOS 7 有一个错误:RcppTOML 无法使用 g++ 4.8.5 (20150623) 编译,但可以使用 scl-devtoolset-4 的 g++ 5.3.1 (20160406) 安装。

sudo yum install centos-release-scl
sudo yum install devtoolset-7-gcc*
scl enable devtoolset-7 bash

这些行解决了问题

如评论中所述,旧版本的 RcppTOML 也可以使用;这是比接受的答案更轻的堆栈。

install.packages("devtools")
require(devtools)
install_version("RcppTOML", version = "0.1.3", repos = "http://cran.us.r-project.org")

要安装旧版本,最简单的方法是使用 devtools。