How to Install Lightgbm? VS Code, Jupyter Notebook, Colab

LightGBM is a boosting algorithm developed by the Mircosoft office that was publically available in 2017. It has gained popularity among data analysts and machine learning developers because of its speed, high accuracy, and many other awesome features. The LightGBM is not a Python built-in module, so we need to install the module before using it. In this post, we will learn how to install LightGBM on VS Code, Jupyter Notebook, Colab, and other text editors.

Check the article on the Hyperparameter tuning of LightGBM.

How to Install LightGBM?

LightGBM is a Python module used in machine learning. It is a boosting algorithm which means it creates multiple weak learning models and combines them to come up with a strong learning model. It can be used for both classification and regression problems along with forecasting as well. Before going to use the model, you need to install the module on your system to get rid of the error Modulenotfounderror: no module named ‘lightgbm’. The error will raise if you don’t have LightGBM on your system or if your installation was not completed.

The simplest way to install the LightGBM module is to use the pip commands in Python. The pip command is used to install various modules in Python.

# for pip version 2
pip install lightgbm

# for pip version 3
pip3 install lightgbm

The installation of the module takes some time as it is quite a large module. After the installation, close the terminal and open the Python script, import the module, and run the script. You will not get the Modulenotfounderror: no module named ‘lightgbm’ error anymore.

Install LightGBM on Windows

Well, many users prefer to stay on Windows. The installation process of any module on Windows is quit simple and straight forwarded. You need to open the terminal on your Windows and type any of the given commands.

# for pip users
pip install lightgbm

pip3 install lightgbm

#using pip3 version
python3 -m pip install lightgbm

# using py alias (Windows)
py -m pip install lightgbm

This will help you to install the module on your Windows:

Install LightGBM on Jupyter Notebook, VS Code, and Colab

Here are some alternative methods and commands to install the LightGBM module on Jupyter Notebook, VS Code, and Colab.

# for jupyter notebook
!pip install lightgbm

# for anaconda
conda install lightgbm

# install on vs code
pip install lightgbm

# on linux operating system
sudo pip3 install scikit-learn

# or this command
pip install scikit-learn --user

Congratulations on installing the module successfully.

How to Import and Use LightGBM Module

After installing the module, you need to import the Lightgbm and then use it. Let us import the module, initialize the LightGBM classifier, and then we will train the model.

# importing the lightgbm
import lightgbm as lgb

Run the script, if you didn’t get any errors, it means the installation was successful. Let us now initialize the classifier and then we will train the model on the training dataset.

# initializing the model
model_Clf = lgb.LGBMClassifier()

# training the model, y_train)

It will take some time to train the model.


LightGBM is getting popular and popular day by day because of its amazing features. It is fast, accurate, and can train on large datasets. In this article, we discussed how to install LightGBM on various platforms including Linux and Windows.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top