open-mmlab/mmdetection · error · RuntimeError

lap is not installed, please install it by:

Error message

lap is not installed,                 please install it by: pip install lap

What it means

OC-SORT tracker performs data association via the 'lap' linear-assignment package. If lap could not be imported, its constructor raises RuntimeError immediately.

Source

Thrown at mmdet/models/trackers/ocsort_tracker.py:55

            association (OCM term in the paper).
        vel_delta_t (int): The difference of time step for calculating of the
            velocity direction of tracklets.
        init_cfg (dict or list[dict], optional): Initialization config dict.
            Defaults to None.
    """

    def __init__(self,
                 motion: Optional[dict] = None,
                 obj_score_thr: float = 0.3,
                 init_track_thr: float = 0.7,
                 weight_iou_with_det_scores: bool = True,
                 match_iou_thr: float = 0.3,
                 num_tentatives: int = 3,
                 vel_consist_weight: float = 0.2,
                 vel_delta_t: int = 3,
                 **kwargs):
        if lap is None:
            raise RuntimeError('lap is not installed,\
                 please install it by: pip install lap')
        super().__init__(motion=motion, **kwargs)
        self.obj_score_thr = obj_score_thr
        self.init_track_thr = init_track_thr

        self.weight_iou_with_det_scores = weight_iou_with_det_scores
        self.match_iou_thr = match_iou_thr
        self.vel_consist_weight = vel_consist_weight
        self.vel_delta_t = vel_delta_t

        self.num_tentatives = num_tentatives

    @property
    def unconfirmed_ids(self):
        """Unconfirmed ids in the tracker."""
        ids = [id for id, track in self.tracks.items() if track.tentative]
        return ids

View on GitHub (pinned to cfd5d3a985)

Solutions

  1. pip install lap
  2. On build failures, use conda-forge or a prebuilt lap wheel
  3. Confirm lap imports in the same env: python -c 'import lap'

Example fix

# before: RuntimeError: lap is not installed
# after
pip install lap
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util
assert importlib.util.find_spec('lap'), 'pip install lap'

Try / catch

try:
    tracker = OCSORTTracker(...)
except RuntimeError as e:
    if 'lap' in str(e):
        raise SystemExit('Missing dependency: pip install lap')
    raise

Prevention

When it happens

Trigger: Instantiating OCSORTTracker (tracker=dict(type='OCSORTTracker')) without the optional lap dependency installed.

Common situations: Running OC-SORT MOT configs on a minimal install; lap missing or failed to compile during env setup.

Related errors


AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27). Data as JSON: /api/errors/ee4dc49acc3a8260. Report an issue: GitHub.