Install & Compatibility
Where this runs
tested against v0.25.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.10
✕ build_error
✕ build_error
275MB installed
● package 275MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
metrics
✓ from river import metrics
✗ import river.metrics
The top-level 'river' submodules are lazy-loaded; accessing via dotted import may fail on first import.
linear_model.LinearRegression
✓ from river import linear_model
✗ from river.linear_model import LinearRegression
While this works, the recommended pattern is to import the module and then access the class.
Basic online learning with a pipeline and metric.
import os
from river import stream, linear_model, metrics, preprocessing
# Simulate a stream of data (dicts)
X_y = [
({'a': 1, 'b': 2}, 3.0),
({'a': 4, 'b': 5}, 9.0),
({'a': 7, 'b': 8}, 15.0),
]
model = preprocessing.StandardScaler() | linear_model.LinearRegression()
metric = metrics.MAE()
for x, y in stream.iter_array(X_y): # stream.iter_array expects tuples (x_dict, y)
y_pred = model.predict_one(x)
if y_pred is not None:
metric.update(y, y_pred)
model.learn_one(x, y)
print(f'MAE: {metric.get():.4f}')
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'river.metrics'
Trying to import a submodule before the parent module is fully loaded; lazy loading causes this.
fixUse `from river import metrics` instead of `import river.metrics`.
AttributeError: 'NoneType' object has no attribute 'predict_one'
Model not instantiated correctly, or pipeline returned None for step.
fixEnsure the model is a callable estimator; check pipeline composition.
ValueError: could not broadcast input array from shape (X,) into shape (Y,)
Mismatched dimensions or data type in streaming examples.
fixEnsure each sample is a dict with matching keys and values are numeric.
RuntimeError: This model has not been trained yet
Called `predict_one` before `learn_one` on models that require training first.
fixAlways call `model.learn_one(x, y)` at least once before prediction.
Upgrade
Version history
0.25.0latest on PyPI · released May 31, 2026
Audit
Dependencies
numpyrequiredCore numerical arrays
pandasoptionalDataFrame conversion and utilities
scipyoptionalOptimization and linear algebra