Lightning-AI/pytorch-lightning · error · MisconfigurationException

Trainer was configured with `enable_progress_bar=False` but

Error message

Trainer was configured with `enable_progress_bar=False` but found `{progress_bar_callback.__class__.__name__}` in callbacks list.

What it means

Raised during Trainer initialization when enable_progress_bar=False is set but a ProgressBar callback (e.g., TQDMProgressBar or RichProgressBar) is present in callbacks. The explicit flag and the explicit callback contradict each other, so Lightning raises rather than guessing intent.

Source

Thrown at src/lightning/pytorch/trainer/connectors/callback_connector.py:148

        self.trainer.callbacks.append(model_summary)

    def _configure_progress_bar(self, enable_progress_bar: bool = True) -> None:
        progress_bars = [c for c in self.trainer.callbacks if isinstance(c, ProgressBar)]
        if len(progress_bars) > 1:
            raise MisconfigurationException(
                "You added multiple progress bar callbacks to the Trainer, but currently only one"
                " progress bar is supported."
            )
        if len(progress_bars) == 1:
            # the user specified the progress bar in the callbacks list
            # so the trainer doesn't need to provide a default one
            if enable_progress_bar:
                return

            # otherwise the user specified a progress bar callback but also
            # elected to disable the progress bar with the trainer flag
            progress_bar_callback = progress_bars[0]
            raise MisconfigurationException(
                "Trainer was configured with `enable_progress_bar=False`"
                f" but found `{progress_bar_callback.__class__.__name__}` in callbacks list."
            )

        if enable_progress_bar:
            progress_bar_callback = RichProgressBar() if _RICH_AVAILABLE else TQDMProgressBar()
            self.trainer.callbacks.append(progress_bar_callback)

    def _configure_timer_callback(self, max_time: Optional[Union[str, timedelta, dict[str, int]]] = None) -> None:
        if max_time is None:
            return
        if any(isinstance(cb, Timer) for cb in self.trainer.callbacks):
            rank_zero_info("Ignoring `Trainer(max_time=...)`, callbacks list already contains a Timer.")
            return
        timer = Timer(duration=max_time, interval="step")
        self.trainer.callbacks.append(timer)

    def _attach_model_logging_functions(self) -> None:

View on GitHub (pinned to 9fed5c27d2)

Solutions

  1. Remove the ProgressBar callback from the list when enable_progress_bar=False
  2. Set enable_progress_bar=True and keep the callback
  3. Conditionally build callbacks: only append the progress bar when the flag is on

Example fix

# before
trainer = Trainer(enable_progress_bar=False, callbacks=[TQDMProgressBar()])
# after
callbacks = [cb for cb in my_callbacks if not isinstance(cb, ProgressBar)]
trainer = Trainer(enable_progress_bar=False, callbacks=callbacks)
Defensive patterns

Strategy: validation

Validate before calling

from lightning.pytorch.callbacks import ProgressBar

if not enable_progress_bar:
    callbacks = [c for c in callbacks if not isinstance(c, ProgressBar)]
trainer = Trainer(enable_progress_bar=enable_progress_bar, callbacks=callbacks)

Type guard

def progress_bar_consistent(enable_progress_bar: bool, callbacks) -> bool:
    from lightning.pytorch.callbacks import ProgressBar
    has_pb = any(isinstance(c, ProgressBar) for c in callbacks)
    return not (has_pb and not enable_progress_bar)

Prevention

When it happens

Trigger: Trainer(enable_progress_bar=False, callbacks=[TQDMProgressBar()]) or any ProgressBar subclass combined with the disabled flag; typical when silencing output for logs/CI while reusing a callback list that contains a progress bar.

Common situations: Running in CI/slurm where output must be suppressed but the shared trainer factory always adds a progress bar; toggling the flag via config without conditioning the callback list.

Related errors


AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28). Data as JSON: /api/errors/c4ff46e6efbfe1c5. Report an issue: GitHub.