mac安装LightGBM with Anaconda

网上很多安装教程有误,或者是太老???

不如直接看官网教程

参考官网 

https://github.com/Microsoft/LightGBM/blob/master/docs/Installation-Guide.rst#osx

 https://github.com/Microsoft/LightGBM/tree/master/python-package


LightGBM depends on OpenMP for compiling, which isn't supported by Apple Clang.

Please install gcc/g++ by using the following commands:

brew install cmake
brew install gcc --without-multilib

Then install LightGBM:

git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
export CXX=g++-7 CC=gcc-7
mkdir build ; cd build
cmake ..
make -j4


For Mac OS X users, gcc with OpenMP support must be installed first. Refer to Installation Guide for installing gcc with OpenMP support.

Note: 32-bit Python is not supported. Please install 64-bit version.

Install from PyPI Using pip

For Windows users, VC runtime is needed if Visual Studio (2015 or 2017) is not installed.

Install wheel via pip install wheel first. After that download the wheel file and install from it:

pip install lightgbm
按照上面的代码敲一遍,即可安装成功

详细参考官网


最后有个问题 ,Anaconda Navigator中没有lightgbm,无法通过此来安装,然后上述安装的时候安装到本地的python3环境下了,问题是我使用Anaconda Navigator中的jupyterlab是Anaconda自己的python环境,和本地不是一个环境,我想在jupyterlab上使用lightgbm,怎么办?【网上没有解】

如下解决:

在本地的python3环境下,导入lightgbm包,使用lightgbm.__file__输出包的路径,然后在Anaconda的python3环境下,导入任意一个包(如xgboost),然后输出该路径;

最后将本地环境中的lightgbm包拷贝到Anaconda的python3包环境下

问题解决

你可能感兴趣的:(机器学习)