How to Install lightgbm in Python
LightGBM Python-package
pip install lightgbm
What is lightgbm?
LightGBM Python-package
32-bit Python is not supported. Please install 64-bit version. If you have a strong need to install with 32-bit Python, refer to .
Compiled library that is included in the wheel file supports both GPU and CPU versions out of the box. This feature is experimental and available only for Windows and Linux currently. To use GPU version you only need to install OpenCL Runtime libraries. For NVIDIA and AMD GPU they are included in the ordinary drivers for your graphics card, so no action is required. If you would like your AMD or Intel CPU to act like a GPU (for testing and debugging) you can install on Windows and on Linux. Many modern Linux distributions provide packages for PoCL, look for `` on RedHat-based distributions.
For Windows users, is needed if Visual Studio (2015 or newer) is not installed.
Quick Start
Minimal example to get started with lightgbm:
import lightgbm
print(lightgbm.__version__)
Installation
pip (standard)
pip install lightgbm
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install lightgbm
pip3
pip3 install lightgbm
conda
conda install -c conda-forge lightgbm
Poetry
poetry add lightgbm
Dependencies
Installing lightgbm will also install these packages:
Verify the Installation
After installing, confirm the package is available:
python -c "import lightgbm; print(lightgbm.__version__)"
If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.
Installation Errors
Common errors when installing lightgbm with pip.
ModuleNotFoundError: No module named 'lightgbm'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install lightgbm. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'lightgbm' (installed but still failing)
Cause: pip installed the package into a different Python than the one running your script.
Fix: Use python -m pip install lightgbm to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'lightgbm'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show lightgbm and upgrade with pip install --upgrade lightgbm.
pip: command not found
Cause: pip is not in PATH or Python was not added to PATH during installation.
Fix: Try python -m pip install lightgbm. On macOS/Linux try pip3.
PermissionError: [Errno 13] Permission denied
Cause: No write access to the system Python package directory.
Fix: Use a virtual environment, or add --user: pip install --user lightgbm
SSL: CERTIFICATE_VERIFY_FAILED
Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.
Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org lightgbm
RuntimeError: CUDA out of memory
Cause: Model or batch size exceeds GPU memory.
Fix: Reduce batch size, call torch.cuda.empty_cache(), or run on CPU.
Recent Releases
| Version | Released |
|---|---|
4.6.0 latest |
2025-02-15 |
4.5.0 |
2024-07-26 |
4.4.0 |
2024-06-15 |
4.3.0 |
2024-01-26 |
4.2.0 |
2023-12-22 |
Manage lightgbm
Upgrade to latest version
pip install --upgrade lightgbm
Install a specific version
pip install lightgbm==4.6.0
Uninstall
pip uninstall lightgbm
Check what is installed
pip show lightgbm