lightgbm+MacOS+Anaconda 环境之疑
1、mac环境下先通过brew安装cmake和gcc
brew install cmake
brew install gcc --without-multilib
之后brew会查找最新的gcc版本进行安装,安装过程中要仔细观察安装的gcc版本,接下来会用到,很重要,如果没注意安装过程并且不小心关掉了终端的话可以到这个路径进行查看:
/usr/local/opt/gcc/lib/gcc/8
2、下面用cmake进行编译
git clone --recursive https://github.com/Microsoft/LightGBM
cd LightGBM
export CXX=g++-8 CC=gcc-8 (注意点)
mkdir build
cd build
cmake ..
make -j4
3.在你自己的anaconda环境中安装我们刚才编译好的lightgbm了
/usr/local/opt/gcc/lib/gcc/8/lightGBM/python-package
首先要进入你的虚拟环境;
在虚拟环境中cd到你下载的LightGBM中的以下路径:
LightGBM/python-package
sudo python setup.py install --precompile
ps:如果用其他的教程直接在虚拟环境中pip install lightgbm之后,运行import lightgbm会报以下错误:Error: dlopen(/Users//anaconda3/envs//lib/python2.7/site-packages/lightgbm/lib_lightgbm.so, 6): Library not loaded: /usr/local/opt/gcc/lib/gcc/7/libgomp.1.dylib
Referenced from: /Users//anaconda3/envs/mouse/lib/python2.7/site-packages/lightgbm/lib_lightgbm.so
Reason: image not found
运行import lightgbm会报以下错误:
网友评论