Last modified: Jun 18, 2025 By Alexander Williams

How to Uninstall XGBoost in Python

XGBoost is a popular machine learning library. Sometimes, you may need to uninstall it. This guide will show you how.

Why Uninstall XGBoost?

You might need to uninstall XGBoost for several reasons. Maybe you want to install a different version. Or perhaps you're cleaning up your Python environment.

Whatever the reason, uninstalling XGBoost is simple. You can do it using pip or conda.

Uninstall XGBoost Using pip

The easiest way to uninstall XGBoost is with pip. Open your command line or terminal and run:

 
pip uninstall xgboost

You'll see a confirmation message. Type 'y' and press Enter to proceed.


Proceed (y/n)? y
  Successfully uninstalled xgboost-1.7.0

Uninstall XGBoost Using conda

If you used conda to install XGBoost, use this command instead:

 
conda remove xgboost

Conda will show you what will be removed. Confirm by typing 'y'.

Verify Uninstallation

After uninstalling, verify XGBoost is gone. Try importing it in Python:

 
import xgboost

You should see an error if uninstallation worked:


ModuleNotFoundError: No module named 'xgboost'

Troubleshooting

If you have issues, try these steps:

1. Check if XGBoost is installed with pip list or conda list.

2. Make sure you're using the right Python environment. This is especially important if you use virtual environments.

3. For stubborn cases, try pip uninstall xgboost multiple times.

Clean Up Dependencies

XGBoost may have installed dependencies. You can remove unused ones with:

 
pip autoremove

Or for conda:

 
conda clean --all

Reinstall XGBoost (Optional)

If you need XGBoost again later, install it with:

 
pip install xgboost

Or for conda:

 
conda install -c conda-forge xgboost

Need to uninstall other Python libraries? Check these guides:

How to Uninstall scikit-learn

How to Uninstall Pandas

How to Uninstall Python Libraries

Conclusion

Uninstalling XGBoost is straightforward. Use pip uninstall xgboost or conda remove xgboost. Always verify the uninstallation was successful.

Remember to clean up any leftover dependencies. This keeps your Python environment tidy. For more complex setups, consider using virtual environments.