
- LightGBM - Home
- LightGBM - Overview
- LightGBM - Architecture
- LightGBM - Installation
- LightGBM - Core Parameters
- LightGBM - Boosting Algorithms
- LightGBM - Tree Growth Strategy
- LightGBM - Dataset Structure
- LightGBM - Binary Classification
- LightGBM - Regression
- LightGBM - Ranking
- LightGBM - Implementation in Python
- LightGBM - Parameter Tuning
- LightGBM - Plotting Functionality
- LightGBM - Early Stopping Training
- LightGBM - Feature Interaction Constraints
- LightGBM vs Other Boosting Algorithms
- LightGBM Useful Resources
- LightGBM - Quick Guide
- LightGBM - Useful Resources
- LightGBM - Discussion
LightGBM - Installation and Setup
LightGBM is a popular package for machine learning, mainly for gradient boosting. It is fast and efficient, and it is commonly used for Python model development.
LightGBM installations involve setting up the LightGBM gradient boosting framework on a local workstation or server. This usually involves installing necessary dependencies like compilers and CMake, copying the LightGBM repository from GitHub, building the framework with CMake, and installing the Python package using pip.
Proper installation enables users to take advantage of LightGBM's efficient algorithms and functionality for machine learning jobs.
LightGBM can be installed on a number of operating systems, including Windows, macOS, and Linux. Installation steps may vary depending on your operating system. Here's a simple guide for all operating systems −
Installation on Windows
You have three options for installing LightGBM on Windows-Visual Studio, CMake with Visual Studio Build Tools, and CMake with MinGW. Below are the simplified steps for each method −
Using Visual Studio (GUI)
Here are the steps to install LightGBM using Visual Studio −
Install Visual Studio: First you need to download and install Visual Studio in your system.
Download LightGBM: Go to the LightGBM GitHub repository download the zip archive and unzip it.
Open LightGBM in Visual Studio: Navigate to the LightGBM-master/windows folder and open the LightGBM.sln file in Visual Studio. After that choose the "Release" configuration.
Build LightGBM: Click on BUILD → Build Solution. If you see errors about the Platform Tool-set so go to PROJECT → Properties → Configuration Properties → General and select the correct tool-set for your machine.
Find the Executable: The .exe file will be located in the LightGBM-master/windows/x64/Release folder.
Using Python Package (pip)
This is the easiest way if you are using Python. So open command prompt in your system and run pip command −
pip install lightgbm
This command will automatically download and install the LightGBM package in your windows system.
Using Anaconda
If you have Anaconda installed then you can use the conda package manager. So open Anaconda prompt or just search for "Anaconda Prompt" in the start menu. And run conda command −
conda install -c conda-forge lightgbm
This will automatically install LightGBM package from the conda−forge channel.
Installation on Linux
LightGBM can be installed on Linux using a number of methods as per your system and preferences. There are three common methods −
Using CMake
Here are the steps to install using CMake in Linux −
-
Install Required Dependencies: Open a terminal and install the required packages.
sudo apt-get update sudo apt-get install -y build-essential git cmake libboost-all-dev
-
Now, you have to clone the LightGBM repository −
git clone --recursive https://github.com/microsoft/LightGBM cd LightGBM
-
Build LightGBM: Build LightGBM using the following commands −
mkdir build cd build cmake .. make -j4
Verify Installation: The LightGBM executable (lightgbm) will be available in the LightGBM/build directory.
Using Python Package (pip)
Here are the steps to install using Python Package (pip) in Linux −
-
Install Python and pip: Make sure you have Python (3.5 or higher) and pip installed. Install them as needed.
sudo apt-get update sudo apt-get install -y python3 python3-pip
-
Install LightGBM Using pip: Now run the below command to install LightGBM directly using pip.
pip install lightgbm
-
Verify Installation: Check that the LightGBM is installed by executing the below command −
python3 -c "import lightgbm; print(lightgbm.__version__)"
Installation on MacOS
Here are the steps to install LightGBM on macOS −
Install Using Homebrew
Here are the steps to install using Homebrew in MacOS −
Open the terminal using command + space and type "Terminal" then press Enter.
-
Run the below command in the terminal −
brew install lightgbm
On successful installation this will generates a message similar to the following −

Install LightGBM Using pip
Here are the steps to install using pip in MacOS −
Install the latest version of Python3 in your MacOS.
-
Now you have to check that pip3 and python3 are installed properly or not. Use the below commands −
python3 --version pip3 --version
-
Then you can upgrade your pip to prevent any future errors while installation process.
pip3 install --upgrade pip
-
Now use the below command to install LightGBM in your macOS with the help of pip3.
pip3 install lightgbm
On successful installation this will generates a message similar to the following −

Build from GitHub
Here are the steps to install using Homebrew in MacOS −
-
Install CMake by running this command in the terminal −
brew install cmake
-
Install OpenMP by running the below command −
brew install libomp
-
Now clone the LightGBM repository of github using the below command −
git clone --recursive https://github.com/microsoft/LightGBM cd LightGBM
-
Now you need to build LightGBM using the below commands −
mkdir build cd build cmake .. make -j4
LightGBM is a fast and efficient machine learning package for gradient boosting. Before installing it, the necessary dependencies and tools must be set up. You can then use tools like Visual Studio, CMake, or pip to build and install the package, based on whether you are running Windows, Linux, or macOS.