Skip to content

"Error rendering output item using 'jupyter-ipywidget-renderer'" when running transformers Trainer.train() on Python 3.13 #4017

@guangdawang

Description

@guangdawang

Description

When running Hugging Face transformers' Trainer.train() in Jupyter Notebook, the progress bar fails to render with the error:

Error rendering output item using 'jupyter-ipywidget-renderer'
Cannot read properties of undefined (reading 'ipywidgetsKernel')

The training continues in the background (CPU usage is normal), but the progress bar and loss values are not visible. Adding os.environ['JUPYTER_DISABLE_WIDGETS'] = '1' works around the issue (but loses progress bar functionality).

Reproduce

  1. Create a fresh environment:

    conda create -n ipywidgets-test python=3.13
    conda activate ipywidgets-test
    pip install jupyter ipywidgets transformers torch
  2. Start Jupyter Notebook:

    jupyter notebook
  3. Create a new notebook and run:

    from transformers import Trainer, TrainingArguments, GPT2LMHeadModel, GPT2Tokenizer
    
    # Load model
    model = GPT2LMHeadModel.from_pretrained('gpt2')
    tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
    tokenizer.pad_token = tokenizer.eos_token
    
    # Create training arguments
    training_args = TrainingArguments(
        output_dir='./test',
        num_train_epochs=1,
        per_device_train_batch_size=1,
        logging_steps=1,
    )
    
    # Create trainer (progress bar should appear even without dataset)
    trainer = Trainer(
        model=model,
        args=training_args,
    )
    
    # Run training - error appears here
    trainer.train()
  4. Observe the red error message in the progress bar area

Expected behavior

The progress bar should display normally, showing:

  • Epoch progress (e.g., 1/3)
  • Current step
  • Loss values
  • Estimated time remaining

Context

  • ipywidgets version: 8.1.8
  • Operating System: WSL2 (Linux 6.6.87.2-microsoft-standard-WSL2) on Windows 11
  • Browser: Chrome latest (also tested on Firefox, same issue)
Troubleshoot Output
Selected Jupyter core packages...
IPython          : 9.11.0
ipykernel        : 7.2.0
ipywidgets       : 8.1.8
jupyter_client   : 8.8.0
jupyter_core     : 5.9.1
jupyter_server   : 2.17.0
jupyterlab       : 4.5.6
nbclient         : 0.10.4
nbconvert        : 7.17.0
nbformat         : 5.10.4
notebook         : 7.5.5
traitlets        : 5.14.3

Other key package versions:

  • transformers: 5.3.0
  • torch: 2.10.0
  • Python: 3.13.12
Command Line Output
Start command: jupyter notebook
Output: [I 2026-03-13 10:30:00.123 LabApp] JupyterLab 4.5.6 is running at:
[I 2026-03-13 10:30:00.123 LabApp] http://localhost:8888/lab
[I 2026-03-13 10:30:00.123 LabApp] or http://127.0.0.1:8888/lab
(Normal startup, no errors)
Browser Output
Browser console error:
Error rendering output item using 'jupyter-ipywidget-renderer'
Cannot read properties of undefined (reading 'ipywidgetsKernel')
    at w (https://localhost:8888/static/lab/vendors-node_modules_@jupyter-widgets_html-manager_lib_index_js.xxx.js:1:xxxxx)
    ...

If using JupyterLab

  • JupyterLab version: 4.5.6
Installed Labextensions
JupyterLab v4.5.6
(no additional labextensions, pure default installation)

Additional Notes

  1. Issue only occurs with training progress bar: Other widgets in the notebook (like simple IPython.display) work fine
  2. Temporary workaround works: Setting os.environ['JUPYTER_DISABLE_WIDGETS'] = '1' disables widgets and training proceeds normally (but with text output instead of progress bar)
  3. Possible relevant factors:
    • Python 3.13 is very new (released in 2025)
    • transformers 5.3.0 is also the latest version
    • ipywidgets 8.x + Jupyter 7.x combination might have compatibility issues with new Python versions
  4. Suggestions:
    • Could ipywidgets be tested with Python 3.13?
    • Could transformers provide a fallback option to force simple text progress bar?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions