Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am stuck with lightgbm R installation. Please Help #2997

Closed
varunmmm opened this issue Apr 14, 2020 · 14 comments
Closed

I am stuck with lightgbm R installation. Please Help #2997

varunmmm opened this issue Apr 14, 2020 · 14 comments

Comments

@varunmmm
Copy link

I have tried many things to get this package installed in R but couldn't do it. So i am following exact same steps mentioned in below post but getting error. Somebody please help me out it's killing my time and i am just frustrated with this.

https://github.com/microsoft/LightGBM/issues/912#issuecomment-329496254

Error message below

image

@jameslamb
Copy link
Collaborator

Hello @varunmmm , I'd like to help you! Can you please provide answers to the following:

  1. What version of Windows are you on?
  2. How are you installing lightgbm? (exact code you ran)
    • there have been a LOT of changes to LightGBM's R package since the post that you linked (September 2017). The official documentation is .
  3. Do you have CMake installed? If so what version?
  4. Do you have Visual Studio installed? If so what version?
  5. Do you have Rtools35 installed?

Assuming you have followed [our installation instructions]((https://github.com/microsoft/LightGBM/blob/master/R-package/README.md#installation), the following should allow you to build the R package:

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

Yesterday we got a report (#2995) that suggested that installation is broken right now with Visual Studio. It was a different error message than you're getting, but maybe the same root cause. If the code I posted above doesn't work for you, you can try with the fixes we have coming in #2963 (#2995 (comment))

git clone --recursive https://github.com/jameslamb/LightGBM
cd LightGBM
git fetch origin r/msvc-support
git checkout r/msvc-support
Rscript build_r.R

Please let me know the answers to those questions and whether or not either code snippet works. Hopefully I can get you up and running soon. Apologies for the frustration.

@varunmmm
Copy link
Author

varunmmm commented Apr 15, 2020

Hi @jameslamb thanks for your prompt response. Please find my response below :

  1. What version of Windows are you on? - Windows 10
  2. How are you installing lightgbm? (exact code you ran) - I am following the instruction process same as shared by you
  3. Do you have CMake installed? If so what version? - Yes installed, version 3.17.1
  4. Do you have Visual Studio installed? If so what version? - Yes installed, version 2019
  5. Do you have Rtools35 installed? - Yes installed

So I have followed the instructions you mentioned above. Now getting error stating "Rscript is not recognized". I have updated system variables as well not sure why this error is coming?

image

System variables update Screenshot

image

@jameslamb
Copy link
Collaborator

Ok great. I know that on #2995 we got a report that versions of CMake 3.17.x might not work well with our installation and you may need to downgrade to 3.12.x (#2995 (comment)). I haven't confirmed that yet but it did work for that person.

Rscript not being found is unrelated to any of the code I linked you to, so you'll need to figure that out first, then repeat the steps I provided and share the output. I'm not a Windows expert, but I can see that every path in your environment variables is a single path except the highlighted line. So try adding each entry individually with New instead of putting them on all in one entry.

@StrikerRUS
Copy link
Collaborator

@varunmmm

System variables update Screenshot

I can see from your screenshot that you added paths of executables, but paths of folders should be there.
Remove Rscript and cmake last path pieces and then you should be able to run Rscript and CMake.

@varunmmm
Copy link
Author

Hi Both @jameslamb @StrikerRUS

I have just changed path as suggested by @StrikerRUS, so removed Rscript and CMake. So Rscript is can be recognized by system but now getting another error.

image

Updated system variables path now

image

@StrikerRUS
Copy link
Collaborator

Hmm, looks like escaping issue (C:/Program, Files/R/R-3.6.2/...). As a hot fix, please try to build the package from any folder without whitespaces in its full path.

@varunmmm
Copy link
Author

Hi @StrikerRUS really appreciate your effort. I tried to build package from different folder which doesn't has whitespace. Now getting package dependency error but i do have all packages mentioned in below error message.

image

@jameslamb
Copy link
Collaborator

I did not notice in your previous screenshot that you were running code from inside of C:\Program Files\R\R-3.6.2\library\! It is dangerous to run any code code there, since R (like many other Windows programs) relies on a particular directory structure and contents of its Program Files directory.

Please remove any files in C:\Program Files\R\R-3.6.2\library\LightGBM. It's possible that working there broke your R installation's ability to find packages. I expect that that is why you got those things like invalid package.... R assumes that each directory under C:\Program Files\R\R-3.6.2\library is the name of a package.

If you run Rscript -e "library(data.table)" what happens? What about the output of Rscript -e "cat(.libPaths())"?

Also, could you please copy the outputs and paste them as text here instead of screenshots? It will hep others searching our issues for similar messages.

Finally...could you try from a plain CMD shell, not Git Bash for Windows? It's possible that the PATH for the Git shell is different from the system one (like this example)

@varunmmm
Copy link
Author

@jameslamb I have done below changes now :

  1. Removed LightGBM folder from C:\Program Files\R\R-3.6.2\library\LightGBM
  2. Using CMD Shell
  3. Reinstall Rtools so now not getting that package dependency error.

When I run Rscript build_r.R getting below error:

`D:\LightGBM>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
    WARNING: directory 'lightgbm/src/compute/test' is empty

  • looking to see if a 'data/datalist' file should be added

  • building 'lightgbm_2.3.2.tar.gz'

  • installing to library 'C:/Users/Varun Yadav/Documents/R/win-library/3.6'

  • installing source package 'lightgbm' ...
    ** using staged installation
    ** libs
    installing via 'install.libs.R' to C:/Users/Varun Yadav/Documents/R/win-library/3.6/00LOCK-lightgbm/00new/lightgbm
    [1] "Trying to build with: 'Visual Studio 16 2019'"
    -- The C compiler identification is MSVC 19.25.28614.0
    -- The CXX compiler identification is MSVC 19.25.28614.0
    -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe
    -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe
    -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    R version passed into FindLibR.cmake: 3.6.2
    Warning message:
    In normalizePath(path.expand(path), winslash, mustWork) :
    path[1]="C:/PROGRA1/R/R-361.2/lib": The system cannot find the file specified
    Creating R.lib and R.def
    CMake Error at cmake/modules/FindLibR.cmake:40 (message):
    LIBR_LIB_DIR, 'C:/PROGRA1/R/R-361.2/lib', not found
    Call Stack (most recent call first):
    cmake/modules/FindLibR.cmake:194 (create_rlib_for_msvc)
    CMakeLists.txt:76 (find_package)

-- Configuring incomplete, errors occurred!
See also "C:/Users/Varun Yadav/AppData/Local/Temp/RtmpMPd84u/R.INSTALL1480478b3f01/lightgbm/src/build/CMakeFiles/CMakeOutput.log".
[1] "Trying to build with: 'Visual Studio 15 2017'"
CMake Error at CMakeLists.txt:7 (PROJECT):
Generator

Visual Studio 15 2017

could not find any instance of Visual Studio.

-- Configuring incomplete, errors occurred!
See also "C:/Users/Varun Yadav/AppData/Local/Temp/RtmpMPd84u/R.INSTALL1480478b3f01/lightgbm/src/build/CMakeFiles/CMakeOutput.log".
[1] "Trying to build with: 'Visual Studio 14 2015'"
-- Selecting Windows SDK version to target Windows 10.0.18362.
CMake Error at CMakeLists.txt:7 (PROJECT):
Failed to run MSBuild command:

C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe

to get the value of VCTargetsPath:

Microsoft (R) Build Engine version 14.0.23107.0
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 16-04-2020 13:46:58.
Project "C:\Users\Varun Yadav\AppData\Local\Temp\RtmpMPd84u\R.INSTALL1480478b3f01\lightgbm\src\build\CMakeFiles\3.17.1\VCTargetsPath.vcxproj" on node 1 (default targets).
C:\Users\Varun Yadav\AppData\Local\Temp\RtmpMPd84u\R.INSTALL1480478b3f01\lightgbm\src\build\CMakeFiles\3.17.1\VCTargetsPath.vcxproj(14,2): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Done Building Project "C:\Users\Varun Yadav\AppData\Local\Temp\RtmpMPd84u\R.INSTALL1480478b3f01\lightgbm\src\build\CMakeFiles\3.17.1\VCTargetsPath.vcxproj" (default targets) -- FAILED.

Build FAILED.

"C:\Users\Varun Yadav\AppData\Local\Temp\RtmpMPd84u\R.INSTALL1480478b3f01\lightgbm\src\build\CMakeFiles\3.17.1\VCTargetsPath.vcxproj" (default target) (1) ->
  C:\Users\Varun Yadav\AppData\Local\Temp\RtmpMPd84u\R.INSTALL1480478b3f01\lightgbm\src\build\CMakeFiles\3.17.1\VCTargetsPath.vcxproj(14,2): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.02

Exit code: 1

-- Configuring incomplete, errors occurred!
See also "C:/Users/Varun Yadav/AppData/Local/Temp/RtmpMPd84u/R.INSTALL1480478b3f01/lightgbm/src/build/CMakeFiles/CMakeOutput.log".
[1] "Building with Visual Studio failed. Attempted with MinGW"
-- The C compiler identification is GNU 4.9.3
-- The CXX compiler identification is GNU 4.9.3
-- Check for working C compiler: C:/Rtools/mingw_64/bin/gcc.exe
-- Check for working C compiler: C:/Rtools/mingw_64/bin/gcc.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Rtools/mingw_64/bin/g++.exe
-- Check for working CXX compiler: C:/Rtools/mingw_64/bin/g++.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
R version passed into FindLibR.cmake: 3.6.2
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:/PROGRA1/R/R-361.2/lib": The system cannot find the file specified
CMake Error at C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
Could NOT find LibR (missing: LIBR_CORE_LIBRARY)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
cmake/modules/FindLibR.cmake:202 (find_package_handle_standard_args)
CMakeLists.txt:76 (find_package)

-- Configuring incomplete, errors occurred!
See also "C:/Users/Varun Yadav/AppData/Local/Temp/RtmpMPd84u/R.INSTALL1480478b3f01/lightgbm/src/build/CMakeFiles/CMakeOutput.log".
R version passed into FindLibR.cmake: 3.6.2
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:/PROGRA1/R/R-361.2/lib": The system cannot find the file specified
CMake Error at C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
Could NOT find LibR (missing: LIBR_CORE_LIBRARY)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
cmake/modules/FindLibR.cmake:202 (find_package_handle_standard_args)
CMakeLists.txt:76 (find_package)

-- Configuring incomplete, errors occurred!
See also "C:/Users/Varun Yadav/AppData/Local/Temp/RtmpMPd84u/R.INSTALL1480478b3f01/lightgbm/src/build/CMakeFiles/CMakeOutput.log".
MINGW3~1.EXE: *** No rule to make target '_lightgbm'. Stop.
Error in eval(ei, envir) : Cannot find lib_lightgbm.dll

  • removing 'C:/Users/Varun Yadav/Documents/R/win-library/3.6/lightgbm'
    Error in .run_shell_command(cmd) : Command failed with exit code: 1
    Execution halted`

@jameslamb
Copy link
Collaborator

Great! Seems like your R setup is fixed. Now the error you're getting looks very similar to the one reported in #2995. As I mentioned in #2997 (comment), can you p lease try the fix from that issue? We're trying to get it merged soon.

git clone --recursive https://github.com/jameslamb/LightGBM
cd LightGBM
git fetch origin r/msvc-support
git checkout r/msvc-support
Rscript build_r.R

@varunmmm
Copy link
Author

varunmmm commented Apr 16, 2020

Ohh God I can't believe this, Finally it worked !!
Thanks @jameslamb for your dedicated support. You are awesome man!! :)

@jameslamb
Copy link
Collaborator

Woo! Thanks for sticking with it and for using LightGBM! We have several pull requests coming up in the next 30 days that should make the installation process for R a lot easier.

I'll close this issue, come back any time if you face other difficulties.

@ghost
Copy link

ghost commented May 10, 2020

Hi everyone,

I'm using Windows 10, RStudio 3.6.3 and I'm trying to install "lightgbm" package in R. I have tried everything I guess but I can not install it. Does it work on RStudio and how can I install it successfully?
p.s: I'm new at this so I'd be grateful if you could explain it step by step.

Thank you so much.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants