Last modified: Jun 04, 2025 By Alexander Williams

Install CatBoost in Python

CatBoost is a powerful machine learning library. It is designed for gradient boosting on decision trees. It works well with categorical data.

This guide will show you how to install CatBoost in Python. You will also learn basic usage examples.

Prerequisites

Before installing CatBoost, ensure you have Python installed. Python 3.6 or higher is recommended.

You should also have pip installed. Pip is Python's package manager. It makes installing libraries easy.

If you need help setting up Python, check our guide on installing Python build tools.

Install CatBoost Using pip

The easiest way to install CatBoost is using pip. Open your command line or terminal.

Run the following command:


pip install catboost

This will download and install the latest version of CatBoost. It includes all required dependencies.

Verify the Installation

After installation, verify it works. Launch Python in your terminal.

Try importing CatBoost:

 
import catboost
print(catboost.__version__)

You should see the version number. For example:


1.2.1

Install Specific Version

Sometimes you need a specific version. Specify the version with pip.

For example, to install version 1.0.0:


pip install catboost==1.0.0

Install with GPU Support

CatBoost can use GPU for faster training. Install the GPU version if you have an NVIDIA GPU.

Use this command:


pip install catboost-gpu

Note: You need CUDA and cuDNN installed for GPU support.

Basic CatBoost Example

Here's a simple example to test CatBoost. We'll use a small dataset.

 
from catboost import CatBoostClassifier
from sklearn.datasets import load_iris

# Load dataset
data = load_iris()
X, y = data.data, data.target

# Create model
model = CatBoostClassifier(iterations=10)

# Train model
model.fit(X, y)

# Make prediction
print(model.predict([[5.1, 3.5, 1.4, 0.2]]))

The output should be:


[0]

Troubleshooting

If you encounter errors during installation, try these solutions:

1. Update pip first: pip install --upgrade pip

2. Use a virtual environment to avoid conflicts.

3. Check our guide on Python testing tools for environment setup tips.

Conclusion

Installing CatBoost in Python is straightforward. Use pip for quick installation. The GPU version offers better performance.

CatBoost is great for machine learning tasks. It handles categorical data well. For more Python guides, check our tutorial on Flask-SQLAlchemy installation.

Now you're ready to use CatBoost in your projects. Happy coding!