M1芯片mac安装xgboost和lightgbm
首先需要配置罗赛塔2的环境(否则的话不能安装默认为Intel芯片的库)
mac终端下执行命令:
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
然后基于国内源安装homebrew,执行命令:
arch -x86_64 /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
以上命令输入后按照提示操作即可,推荐选择中科大或者清华源
然后可以利用配置的环境安装两个库,由于我这里import xgboost时报错是提示library can not be loaded,所以执行如下命令:
arch -x86_64 brew install cmake
arch -x86_64 brew install gcc
git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
export CXX=g++-7 CC=gcc-7
mkdir build ; cd build
cmake ..
make -j4
最后安装利用pip安装两个库即可
pip install lightGBM