Last modified: Jun 16, 2026

Install River for Python ML

River is a powerful Python library for streaming machine learning. It handles data that arrives over time. This guide shows you how to install River quickly and correctly.

What is River?

River is built for online learning. It processes one sample at a time. This is different from batch learning. River works well with data streams from sensors, web logs, or financial markets.

River provides tools for classification, regression, clustering, and anomaly detection. It also has feature extraction and model evaluation. You need it for real-time predictions.

Prerequisites

Before installing River, check your system. You need Python 3.8 or higher. Use a 64-bit operating system. River works on Linux, macOS, and Windows.

You also need pip, the Python package manager. Most Python installations include it. Check your Python version with this command:


python --version

The output should show Python 3.8 or newer. If not, update Python first.

Method 1: Install with pip

Using pip is the simplest method. Open your terminal or command prompt. Run this command:


pip install river

This downloads the latest stable version. It also installs dependencies like NumPy and pandas. Wait for the process to finish. You should see a success message.

Verify the installation with a small test:


import river
print(river.__version__)

Run this script. The output shows the version number. For example:


0.21.0

If you see an error, check your internet connection. Also ensure pip is up to date. Use pip install --upgrade pip before retrying.

Method 2: Install with Conda

If you use Anaconda or Miniconda, use conda. River is available on the conda-forge channel. Run this command:


conda install -c conda-forge river

This method manages dependencies well. It avoids conflicts with other packages. Conda also provides pre-built binaries for faster installation.

Test it the same way as with pip. Import the library and check the version. Conda installs River in the current environment. Use conda activate to switch environments if needed.

Method 3: Install from Source

For the latest features, install from source. This is useful for developers. First, clone the River repository from GitHub:


git clone https://github.com/online-ml/river.git
cd river

Then build and install the package:


pip install -e .

The -e flag installs in editable mode. Changes to the source code take effect immediately. This is great for contributions or custom modifications.

Building from source requires a C++ compiler. On Linux, install build-essential. On macOS, install Xcode command line tools. On Windows, use Visual Studio Build Tools.

After installation, run the test suite to confirm everything works:


python -m pytest

All tests should pass. If some fail, check the error messages. They often point to missing dependencies.

Common Installation Issues

Some users face problems. Here are solutions for common errors.

Error: No module named 'river'. This means the installation failed. Reinstall with pip install --force-reinstall river. Also check your Python environment. You might be using a different interpreter.

Error: Permission denied. On Linux or macOS, use sudo before the pip command. Or install in a virtual environment. Virtual environments avoid permission issues.

Error: Failed building wheel. This happens on older systems. Update pip and setuptools: pip install --upgrade pip setuptools wheel. Then try again.

Setting Up a Virtual Environment

Virtual environments isolate your projects. They prevent dependency conflicts. Create one for River:


python -m venv river_env
source river_env/bin/activate  # On Linux/macOS
river_env\Scripts\activate     # On Windows

Now install River inside this environment. This keeps your main Python installation clean. You can delete the environment later without affecting other projects.

First Streaming Example

Let's test River with a simple example. This code creates a streaming classifier:


from river import linear_model
from river import metrics
from river import datasets

# Load a streaming dataset
dataset = datasets.Phishing()

# Create a logistic regression model
model = linear_model.LogisticRegression()

# Create a metric for accuracy
metric = metrics.Accuracy()

# Stream through the data
for x, y in dataset:
    y_pred = model.predict_one(x)
    model = model.learn_one(x, y)
    metric = metric.update(y, y_pred)

# Print final accuracy
print(f"Accuracy: {metric.get()}")

Run this code. The output shows the model's accuracy on the phishing dataset:


Accuracy: 0.8875

This example shows how River processes data one sample at a time. The model updates after each prediction. This is the core of streaming machine learning.

Why Use River?

River is lightweight and fast. It supports many algorithms. You can use it for online learning, concept drift detection, and real-time analytics. It integrates well with other Python libraries.

For data streams, River beats batch learning. It uses less memory. It adapts to changes over time. This makes it ideal for production systems.

Next Steps

After installation, explore River's documentation. Try different models and datasets. Build a streaming pipeline for your own data.

River also works with other tools. You can combine it with Flask for web APIs. Or use it with Kafka for message streams. The possibilities are endless.

Conclusion

Installing River for streaming machine learning is straightforward. Use pip, conda, or source installation. Each method works on major operating systems. Always verify the installation with a test script. Set up a virtual environment for clean development. With River installed, you can build powerful online learning systems. Start streaming today.