LoginSignup
7
6

More than 5 years have passed since last update.

LightGBMをOSX virtualenv環境にインストールする

Posted at

はじめに

Kaggleのこちらの記事にてLightGBMが用いられていた。
下記のページでも、LightGBMはKaggleでよく話題に上がると紹介されています。

本ページでは、自分が手元のOSX virtualenv環境にlightGBMをインストールした際の流れを記載します。

流れ

下記にインストールガイドがあるため、そちらを参照。

インストールしたい環境の配下にて下記を実施しました。

$ brew install cmake
$ brew install gcc --without-multilib
$ git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
$ mkdir build ; cd build
$ cmake .. 
$ make -j 

cmake ..の際に、下記のようなエラーが発生するかもしれません。

$ cmake .. 
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:8 (PROJECT):
  The CMAKE_C_COMPILER:

    gcc-7

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:8 (PROJECT):
  The CMAKE_CXX_COMPILER:

    g++-7

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.

僕の場合、こちらはgccのバージョンが低かったことが原因のようで、upgradeを行うことで解決しました。

$ brew upgrade gcc

続いて下記を参考に、import できるようにします。

依存関係のあるライブラリをまずインストールします。

$ pip install setuptools numpy scipy scikit-learn -U

/LightGBM/python-package/に移動し下記を実行すれば完了です。

$ python setup.py install

無事importできました。

import lightgbm as lgb

おわりに

ありがとうございました。

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6