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.
Solutions
- Remove the ProgressBar callback from the list when enable_progress_bar=False
- Set enable_progress_bar=True and keep the callback
- 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
- Derive the callback list from the flag in your trainer factory
- In CI configs, filter progress bars out instead of just flipping the flag
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
- Trainer was configured with `enable_checkpointing=False`…
- You added multiple progress bar callbacks to the Trainer…
- Found more than one stateful callback of type
- f"`check_val_every_n_epoch` should be an integer, found
- f"`reload_dataloaders_every_n_epochs` should be an int >=…
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/c4ff46e6efbfe1c5.
Report an issue: GitHub.
Appendix: 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)