mac Mojave (10.14) python3 安装lightgbm
原创
©著作权归作者所有:来自51CTO博客作者是念的原创作品,请联系作者获取转载授权,否则将追究法律责任
今天成功安装了lightgbm,这里分享一下安装的经历首先安装:
brew install cmake
brew install libomp
然后获取lightgbm源代码:
git clone --recursive https://github.com/microsoft/LightGBM
cd LightGBM
mkdir build
cd build
编译:
cmake \
-DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I$(brew --prefix libomp)/include" \
-DOpenMP_C_LIB_NAMES="omp" \
-DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I$(brew --prefix libomp)/include" \
-DOpenMP_CXX_LIB_NAMES="omp" \
-DOpenMP_omp_LIBRARY=$(brew --prefix libomp)/lib/libomp.dylib \
..
最后运行:
然后相关的依赖就安装完毕,最后安装python的包:
安装完以后测试一下:
>>> import lightgbm
/usr/local/lib/python3.7/site-packages/lightgbm/__init__.py:46: UserWarning: Starting from version 2.2.1, the library file in distribution wheels for macOS is built by the Apple Clang (Xcode_8.3.3) compiler.
This means that in case of installing LightGBM from PyPI via the ``pip install lightgbm`` command, you don't need to install the gcc compiler anymore.
Instead of that, you need to install the OpenMP library, which is required for running LightGBM on the system with the Apple Clang compiler.
You can install the OpenMP library by the following command: ``brew install libomp``.
"You can install the OpenMP library by the following command: ``brew install libomp``.", UserWarning)
>>> print(lightgbm.__version__)
2.2.3
参考文献
[1].Installation Guide. https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html#macos