- mac版本:10.13.4
根据lightgbm官方的安装指南,首先需要安装brew。
curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1
上述命令执行完成后执行:
brew
- 提示为:Please run brew update
更新brew:
brew update
- 报错:Error: /usr/local must be writable!
赋给/usr/local目录权限:
sudo chown -R username /usr/local
- 其中username为系统当前用户名
- 报错:Operation not permitted
卸载重装homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
根据官方提示,安装lightgbm。
brew install cmake
brew install gcc
安装lightGBM:
git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
export CXX=g++-7 CC=gcc-7 # 将7替换成当前机器上的gcc版本,否怎可能报错Could not find compiler set in environment variable CC。
mkdir build ; cd build
cmake ..
make -j4
若执行完成后无法识别lightgbm模块,则再执行一次:
sudo pip install lightgbm
若运行import lightgbm时报错image not found,则转到lightGBM/python-pachage目录下,运行
sudo python setup.py install --precompile
即可