LightGBM 包未安装在 windows 机器上

LightGBM package not installing on a windows machine

我正在尝试在我的 windows 笔记本电脑上安装 LightGBM。我已将其安装在 AWS Ubuntu/Lunix 实例上,但我的 windows 笔记本电脑上一直出现错误...

在终端中使用我的 RStudio windows 版本 I 运行:

git clone --recursive https://github.com/microsoft/LightGBM
cd LightGBM
Rscript build_r.R

给出以下输出:

Microsoft Windows [Versión 10.0.17763.1039]
(c) 2018 Microsoft Corporation. Todos los derechos reservados.   # Spanish but all rights reserved.

C:\Users\USER\Documents>git clone --recursive https://github.com/microsoft/LightGBM
Cloning into 'LightGBM'...
remote: Enumerating objects: 207, done.
remote: Counting objects: 100% (207/207), done.
remote: Compressing objects: 100% (172/172), done.

Receiving objects: 100% (16659/16659), 11.36 MiB | 1.86 MiB/s, done.
Resolving deltas: 100% (12071/12071), done.
Submodule 'include/boost/compute' (https://github.com/boostorg/compute) registered for path 'compu
te'
Cloning into 'C:/Users/USER/Documents/LightGBM/compute'...
remote: Enumerating objects: 21728, done.
remote: Total 21728 (delta 0), reused 0 (delta 0), pack-reused 21728
Receiving objects: 100% (21728/21728), 8.51 MiB | 1.79 MiB/s, done.
Resolving deltas: 100% (17565/17565), done.
Submodule path 'compute': checked out '36c89134d4013b2e5e45bc55656a18bd6141995a'

C:\Users\USER\Documents>cd LightGBM

C:\Users\USER\Documents\LightGBM>Rscript build_r.R
* checking for file 'lightgbm_r/DESCRIPTION' ... OK
* preparing 'lightgbm':
* checking DESCRIPTION meta-information ... OK
* cleaning src
Warning in cleanup_pkg(pkgdir, Log) :
  unable to run 'make clean' in 'src'
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* looking to see if a 'data/datalist' file should be added
* building 'lightgbm_2.3.2.tar.gz'

* installing to library 'C:/Users/USER/Documents/R/win-library/3.6'
* installing *source* package 'lightgbm' ...
** using staged installation
** libs
Warning in system(cmd) : 'make' not found
ERROR: compilation failed for package 'lightgbm'
* removing 'C:/Users/USER/Documents/R/win-library/3.6/lightgbm'
Error in .run_shell_command(cmd) : Command failed with exit code: 1
Ejecución interrumpida

错误:Warning in system(cmd) : 'make' not found 我已经多次尝试安装 make 。我也更新了 Rtools。

编辑 1:

Session 信息:

R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=Spanish_Spain.1252  LC_CTYPE=Spanish_Spain.1252    LC_MONETARY=Spanish_Spain.1252
[4] LC_NUMERIC=C                   LC_TIME=Spanish_Spain.1252    

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

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.2        rstudioapi_0.10   magrittr_1.5      usethis_1.5.1     devtools_2.1.0   
 [6] pkgload_1.0.2     R6_2.4.0          rlang_0.4.0       tools_3.6.1       pkgbuild_1.0.4   
[11] sessioninfo_1.1.1 cli_1.1.0         withr_2.1.2       remotes_2.1.0     assertthat_0.2.1 
[16] digest_0.6.21     rprojroot_1.3-2   crayon_1.3.4      processx_3.4.1    callr_3.3.1      
[21] fs_1.3.1          ps_1.3.0          curl_4.0          testthat_2.2.1    memoise_1.1.0    
[26] glue_1.3.1        compiler_3.6.1    desc_1.2.0        backports_1.1.4   prettyunits_1.0.2

编辑 2:

I managed to pass the `make not found` argument, when I run the code now I get.


$ Rscript build_r.R
* checking for file 'lightgbm_r/DESCRIPTION' ... OK
* preparing 'lightgbm':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* looking to see if a 'data/datalist' file should be added
* building 'lightgbm_2.3.2.tar.gz'

* installing to library 'C:/Users/USER/Documents/R/win-library/3.6'
* installing *source* package 'lightgbm' ...
** using staged installation
** libs
installing via 'install.libs.R' to C:/Users/USER/Documents/R/win-library/3.6/00LOCK-lightgbm/00new
/lightgbm
Warning in system(paste0(tmp_cmake_cmd, " ..")) : 'cmake' not found
Warning in system(paste0(tmp_cmake_cmd, " ..")) : 'cmake' not found
Warning in system(paste0(tmp_cmake_cmd, " ..")) : 'cmake' not found
Warning in system(paste0(cmake_cmd, " ..")) : 'cmake' not found
Warning in system(build_cmd) : 'cmake' not found
Error in eval(ei, envir) : Cannot find lib_lightgbm.dll
* removing 'C:/Users/USER/Documents/R/win-library/3.6/lightgbm'
Error in .run_shell_command(cmd) : Command failed with exit code: 1
Ejecución interrumpida

我下载了 cmake 但我仍然遇到同样的错误。

根据您在聊天中的评论,您似乎已将 Rtools 安装到非标准文件夹(C:/Rtools 以外的文件夹),这可能导致 C:/Rtools/bin不属于您的 PATH.

尝试以下方法

Sys.setenv(PATH = paste("C:/Rtools/bin", Sys.getenv("PATH"), sep=";"))

确保更改 "C:/Rtools/bin" 以反映安装 Rtools 的文件夹。

如果文件夹是 C:\rtools40,请更改它

Sys.setenv(PATH = paste("C:/rtools40/bin", Sys.getenv("PATH"), sep=";"))

然后尝试按照官方说明重新安装lightgbm