open-mmlab/mmdetection · error · RuntimeError
sscikit-learn is not installed, please insta
Error message
sscikit-learn is not installed, please install it by: pip install scikit-learn
What it means
KalmanFilter for SORT/DeepSORT tracking needs scipy.linalg (cho_factor/cho_solve) for Mahalanobis gating. If scipy failed to import at module load, HAS_SCIPY is False and constructing the filter raises RuntimeError. The message text mentions scikit-learn but the actual missing package is scipy.
Source
Thrown at mmdet/models/task_modules/tracking/kalman_filter.py:45
Filter, which adaptively modulates the noise scale according to
the quality of detections. More details in
https://arxiv.org/abs/2202.11983. Defaults to False.
"""
chi2inv95 = {
1: 3.8415,
2: 5.9915,
3: 7.8147,
4: 9.4877,
5: 11.070,
6: 12.592,
7: 14.067,
8: 15.507,
9: 16.919
}
def __init__(self, center_only: bool = False, use_nsa: bool = False):
if not HAS_SCIPY:
raise RuntimeError('sscikit-learn is not installed,\
please install it by: pip install scikit-learn')
self.center_only = center_only
if self.center_only:
self.gating_threshold = self.chi2inv95[2]
else:
self.gating_threshold = self.chi2inv95[4]
self.use_nsa = use_nsa
ndim, dt = 4, 1.
# Create Kalman filter model matrices.
self._motion_mat = np.eye(2 * ndim, 2 * ndim)
for i in range(ndim):
self._motion_mat[i, ndim + i] = dt
self._update_mat = np.eye(ndim, 2 * ndim)
# Motion and observation uncertainty are chosen relative to the current
# state estimate. These weights control the amount of uncertainty inView on GitHub (pinned to cfd5d3a985)
Solutions
- pip install scipy (this is the actual missing dependency)
- If it still fails, also install lap and motmetrics which the trackers need next
- Ignore the misleading 'scikit-learn' wording; verify with python -c 'import scipy'
Example fix
# before: RuntimeError: sscikit-learn is not installed # after pip install scipy lap motmetrics
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
assert importlib.util.find_spec('scipy') is not None, 'pip install scipy' Try / catch
try:
kf = KalmanFilter()
except RuntimeError as e:
raise SystemExit('Tracking motion module needs scipy (message mentions scikit-learn but install scipy)') Prevention
- Note the message is misleading — scipy is the real dependency
- Pre-install all tracking extras: pip install scipy lap motmetrics scikit-learn
When it happens
Trigger: Building any SORT/DeepSORT/ByteSORT tracker or motion=dict(type='KalmanFilter') in an environment where scipy is not installed.
Common situations: Minimal mmdetection install used for image detection, then a tracking config (sort_tracker, strongsort) is run; confusingly the error suggests installing scikit-learn, which does not fix it.
Related errors
- trackeval is not installed,please install it by: pip install
- Please run "pip install scipy" to install scipy first.
- sscikit-learn is not installed, please insta
- lap is not installed, please install it by:
- lap is not installed, please install it by:
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/926e80fb266167c9.
Report an issue: GitHub.