setuptools is needed.
For Mac OS X users, gcc with OpenMP support must be installed first. Refer to wiki for installing gcc with OpenMP support.
Note: 32-bit python is not supported. Please install 64-bit version.
Install wheel via pip install wheel
first. For windows user, VC runtime is needed if Visual Studio(2015 or 2017) is not installed.
pip install lightgbm
pip install --no-binary :all: lightgbm
Note: Installation from source package require installing cmake first.
For Windows user, Visual Studio (or MS Build) is needed, and cmake must be version 3.8 or higher.
Install GPU version:
pip install lightgbm --install-option=--gpu
Note: Boost and OpenCL are needed: details for installation can be found in gpu-support. Need to add OpenCL_INCLUDE_DIR to PATH and export BOOST_ROOT before installation.
Install with MinGW on Windows:
pip install lightgbm --install-option=--mingw
Installation from GitHub require installing cmake first.
For Windows user, Visual Studio (or MS Build) is needed, and cmake must be version 3.8 or higher.
git clone --recursive https://github.com/Microsoft/LightGBM
cd LightGBM/python-package
python setup.py install
sudo
(or administrator rights in Windows) may is needed to perform python setup.py install
.
Use python setup.py install --mingw
to use MinGW in Windows.
Use python setup.py install --gpu
to enable GPU support. Boost and OpenCL are needed: details for installation can be found in gpu-support.
Refer to the walk through examples in python-guide folder
Refer to FAQ
The code style of python package follows pep8. If you would like to make a contribution and not familiar with pep-8, please check the pep8 style guide first. Otherwise, the check won't pass. You should be careful about:
- E1 Indentation (check pep8 link above)
- E202 whitespace before and after brackets
- E225 missing whitespace around operator
- E226 missing whitespace around arithmetic operator
- E261 at least two spaces before inline comment
- E301 expected 1 blank line in front of and at the end of a method
- E302 expected 2 blank lines in front of and at the end of a function or a class
E501 can be ignored (line too long).