Last modified: Jun 20, 2025 By Alexander Williams
How to Uninstall LightGBM in Python
LightGBM is a popular gradient boosting framework. Sometimes, you may need to uninstall it. This guide will show you how.
Why Uninstall LightGBM?
You might need to uninstall LightGBM for several reasons. Maybe you want to install a different version. Or you're cleaning up your Python environment.
Whatever the reason, uninstalling is simple. Follow these steps carefully.
Check if LightGBM is Installed
First, verify if LightGBM is installed. Run this command in your terminal or command prompt:
pip show lightgbm
If installed, you'll see package details. If not, you'll get a "not found" message.
Uninstall LightGBM Using pip
The easiest way to uninstall is with pip
. Run this command:
pip uninstall lightgbm
You'll see a confirmation prompt. Type 'y' and press Enter to proceed.
Note: If you installed LightGBM with sudo, you may need to use sudo pip uninstall lightgbm
.
Uninstall LightGBM Using conda
If you used conda to install LightGBM, use this command instead:
conda remove lightgbm
Conda will show packages to be removed. Confirm by typing 'y'.
Verify Uninstallation
After uninstalling, verify it's gone. Run:
import lightgbm
You should get an ImportError
. This confirms successful uninstallation.
Troubleshooting
Sometimes, LightGBM might not uninstall cleanly. Here are some solutions.
Force Uninstall
If normal uninstall fails, try forcing it:
pip uninstall lightgbm --yes
This skips the confirmation prompt.
Remove Residual Files
Check for leftover files in your Python site-packages. Remove any LightGBM folders manually.
Reinstalling LightGBM
After uninstalling, you might want to reinstall. Use:
pip install lightgbm
Or with conda:
conda install -c conda-forge lightgbm
Managing Python Packages
LightGBM is just one of many Python packages. You might also need to uninstall XGBoost or remove scikit-learn sometimes.
For general package management, see our guide on uninstalling Python libraries.
Conclusion
Uninstalling LightGBM is straightforward. Use pip uninstall
or conda remove
. Always verify the uninstallation was successful.
Remember to check for residual files if issues occur. Now you can manage LightGBM installations like a pro!