r - 在 R 中安装最新版本的 xgboost 时出错
问题描述
嗨,尝试时遇到以下错误
`install.packages("xgboost")`
错误信息:
`In file included from amalgamation/xgboost-all0.cc:68:0:
amalgamation/../src/learner.cc: In member function ‘virtual void
xgboost::LearnerImpl::SaveModel(xgboost::Json*) const’:
amalgamation/../src/learner.cc:378:24: error: invalid initialization of non-const reference of type
‘xgboost::Json&’ from an rvalue of type ‘<brace-enclosed initializer list>’
Json& out { *p_out };
^
amalgamation/../src/learner.cc: In member function ‘virtual void
xgboost::LearnerImpl::SaveConfig(xgboost::Json*) const’:
amalgamation/../src/learner.cc:441:24: error: invalid initialization of non-const reference of type
‘xgboost::Json&’ from an rvalue of type ‘<brace-enclosed initializer list>’
Json& out { *p_out };
^
make: *** [amalgamation/xgboost-all0.o] Error 1
ERROR: compilation failed for package ‘xgboost’`
─ 会话信息──────────────────────────────────────────────── ────────────────────────────────
setting value
version R version 3.6.0 (2019-04-26)
os Red Hat Enterprise Linux
system x86_64, linux-gnu
ui RStudio
language (EN)
collate en_AU.UTF-8
ctype en_AU.UTF-8
tz Australia/Brisbane
date 2020-06-08
但是,可以安装较旧的存档版本
packageurl <- "http://cran.r-
project.org/src/contrib/Archive/xgboost/xgboost_0.90.0.2.tar.gz"
install.packages(packageurl, repos=NULL, type="source")
解决方案
如果您是从源代码构建的,也许值得通过命令行(https://xgboost.readthedocs.io/en/latest/build.html#installing-the-development-version)从 github 尝试开发包:
git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
git submodule init
git submodule update
mkdir build
cd build
cmake .. -DR_LIB=ON
make -j$(nproc)
make install
推荐阅读
- c# - Post.Cast<> 升级后不再工作
- git - 将本地未提交的更改移动到新分支
- python - 将这两列从熊猫中的不同数据框中相乘时得到 NaN
- php - 发布到远程 WordPress 站点导致多个元键/元值
- postgresql - postgres 使用可选的键值对构建 json 对象
- javascript - 如何使用 parseFloat 允许逗号?
- python - 未找到“用户创建”的 DRF 反向
- python - Python csv reader for row in reader给出语法错误
- javascript - 无法分配给字符串“”的只读属性“0”
- c# - 将 DbContext 和 ILogger 注入数据库 DAL 构造函数,最佳实践