{"id":645,"library":"ipywidgets","title":"Jupyter Interactive Widgets (ipywidgets)","description":"ipywidgets is a Python library that provides interactive HTML widgets for Jupyter notebooks and the IPython kernel. It enables users to create interactive controls like sliders, text boxes, and buttons, bringing notebooks to life and allowing interactive exploration of data and models. The current version is 8.1.8, and it maintains an active development cycle with regular patch and minor releases, and major versions typically every few years.","status":"active","version":"8.1.8","language":"python","source_language":"en","source_url":"https://github.com/jupyter-widgets/ipywidgets","tags":["jupyter","widgets","interactive","notebook","GUI","data science"],"install":[{"cmd":"pip install ipywidgets","lang":"bash","label":"Install ipywidgets"}],"dependencies":[{"reason":"Automatically installed for classic Jupyter Notebook to display widgets. Explicit installation may be needed if Jupyter components are in separate environments.","package":"widgetsnbextension","optional":true},{"reason":"Automatically installed for JupyterLab 3.x+ to display widgets. Explicit installation may be needed if Jupyter components are in separate environments.","package":"jupyterlab_widgets","optional":true},{"reason":"As of ipywidgets 8, the 'notebook' package is no longer a direct dependency and must be installed explicitly if required for your environment.","package":"notebook","optional":true}],"imports":[{"symbol":"ipywidgets","correct":"import ipywidgets as widgets"},{"symbol":"interact","correct":"from ipywidgets import interact"},{"symbol":"display","correct":"from IPython.display import display"},{"symbol":"Button","correct":"from ipywidgets import Button"},{"symbol":"VBox","correct":"from ipywidgets import VBox"},{"note":"Output is a class, 'out' is often used as an instance variable name.","wrong":"from ipywidgets import out","symbol":"Output","correct":"from ipywidgets import Output"}],"quickstart":{"code":"import ipywidgets as widgets\nfrom IPython.display import display, HTML, clear_output\n\n# Create a simple IntSlider widget\nslider = widgets.IntSlider(\n    min=0,\n    max=100,\n    step=1,\n    description='Value:',\n    value=50\n)\n\n# Create an Output widget to capture print statements\noutput = widgets.Output()\n\n# Define a function to be called when the slider's value changes\ndef on_value_change(change):\n    with output:\n        clear_output()\n        print(f\"Slider value changed to: {change['new']}\")\n\n# Observe changes in the slider's value\nslider.observe(on_value_change, names='value')\n\n# Display the slider and the output area\ndisplay(HTML(\"<h3>Interactive Slider Example</h3>\"))\ndisplay(slider, output)\n","lang":"python","description":"This quickstart demonstrates creating an integer slider, observing its value changes, and displaying updates in a dedicated output area within a Jupyter notebook. It highlights the use of `ipywidgets.IntSlider` and `IPython.display.display` along with `ipywidgets.Output` for controlled output handling."},"warnings":[{"fix":"Rewrite usage of `FileUpload` to access file content and metadata through the new `.value` structure. For example, to get content bytes: `[f.content.tobytes() for f in uploader.value]`.","message":"The `FileUpload` widget API changed significantly in version 8.x. The `.data` and `.metadata` traits were removed, and the `.value` trait was revamped to be a list of dictionaries, each containing file information (e.g., `content`, `name`, `type`, `size`, `last_modified`).","severity":"breaking","affected_versions":"8.x and above"},{"fix":"Replace `description_tooltip` with `tooltip` in your widget instantiations and property assignments.","message":"The `description_tooltip` attribute, used for tooltips on some widgets, was deprecated in favor of a universal `tooltip` attribute available on all widgets inheriting `DOMWidget` in version 8.x.","severity":"breaking","affected_versions":"8.x and above"},{"fix":"Set `description_allow_html=True` explicitly for the widget if you are in full control of the HTML content and require it to be rendered.","message":"The `description` field of most widgets now sanitizes HTML content by default. If you rely on custom HTML in descriptions, it will be stripped or rendered as plain text.","severity":"breaking","affected_versions":"8.x and above"},{"fix":"When initializing `Accordion` or `Tab`, provide titles using the `titles` argument (e.g., `Accordion(children=[...], titles=('Title 1', 'Title 2'))`) or assign to the `_titles` trait after creation.","message":"The method for setting titles on container widgets like `Accordion` or `Tab` changed. Direct calls to `container.set_title(index, title)` can cause `IndexError` if not handled correctly. It is now recommended to initialize with a `titles` tuple or assign to the `_titles` trait.","severity":"breaking","affected_versions":"8.x and above"},{"fix":"Use an `ipywidgets.Output` widget as a context manager to capture and display output reliably. Wrap `print()` calls within a `with output_widget:` block and use `clear_output()` for controlled updates.","message":"Direct `print()` statements within functions linked to widgets (especially with `@interact` or `widget.observe()`) may not always display reliably or may appear in the console instead of the notebook output area in newer Jupyter environments.","severity":"gotcha","affected_versions":"All versions, more prominent in JupyterLab 3+ / Notebook 7+"}],"env_vars":null,"last_verified":"2026-05-12T17:13:17.881Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Install `ipywidgets` using pip or conda: `pip install ipywidgets` or `conda install ipywidgets`. Ensure you install it in the same environment that your Jupyter kernel is using.","cause":"The `ipywidgets` Python package is not installed in the active Python environment or the Jupyter kernel where you are trying to use it.","error":"ModuleNotFoundError: No module named 'ipywidgets'"},{"fix":"Ensure `ipywidgets` and the corresponding JupyterLab or classic Notebook extensions are installed and enabled. For JupyterLab 3.x+, use `pip install jupyterlab_widgets`. For older Jupyter Notebook, use `jupyter nbextension enable --py --sys-prefix widgetsnbextension`. After installation, restart Jupyter and perform a hard refresh of your browser page (Ctrl+Shift+R or Cmd+Shift+R).","cause":"The Jupyter (Notebook/Lab) frontend extension for `ipywidgets` is either not installed, not enabled, or not correctly configured for the current environment, preventing the browser from rendering interactive controls. This can also be due to an outdated browser cache or an incompatible Jupyter version.","error":"Error displaying widget / widgets displaying as text (e.g., VBox(children=(Button(...))))"},{"fix":"Consult the `ipywidgets` documentation for the correct API for your installed version and update your code accordingly. If the attribute belongs to a custom widget, ensure that specific widget's package is installed and compatible with your `ipywidgets` version. Restarting the Python kernel may also help.","cause":"This error often indicates an API incompatibility, typically when upgrading `ipywidgets` (e.g., from version 7 to 8), where a feature, class, or attribute has been removed or renamed. It can also occur if a specific widget is not part of the core `ipywidgets` library.","error":"AttributeError: module 'ipywidgets' has no attribute '...' (e.g., 'TagsInput', '_ipython_display_')"},{"fix":"Try disabling any potentially conflicting Jupyter Notebook extensions (e.g., 'Limit Output'). Verify that the Jupyter kernel is running and healthy. Restart the kernel and rerun all cells in the notebook. A hard refresh of your browser or trying a different browser may also resolve the issue.","cause":"The callback function associated with `interact` is not being triggered, which can stem from conflicting Jupyter Notebook extensions, an unhealthy kernel state, or JavaScript execution issues within the browser environment.","error":"`ipywidgets.interact` shows the widget itself but does not apply the function"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":"8.1.8","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":1.45,"mem_mb":28,"disk_size":"79.2M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.4,"mem_mb":27.9,"disk_size":"56.2M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":5,"import_time_s":1.04,"mem_mb":28,"disk_size":"80M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.02,"mem_mb":27.9,"disk_size":"57M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":2.12,"mem_mb":32.3,"disk_size":"83.7M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.2,"mem_mb":32.1,"disk_size":"59.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":5.5,"import_time_s":1.82,"mem_mb":32.3,"disk_size":"84M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.69,"mem_mb":32.1,"disk_size":"60M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":2.09,"mem_mb":31.5,"disk_size":"74.5M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.04,"mem_mb":31.3,"disk_size":"50.5M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":5,"import_time_s":2.06,"mem_mb":31.5,"disk_size":"75M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.13,"mem_mb":31.3,"disk_size":"51M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":2.1,"mem_mb":33,"disk_size":"74.3M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.13,"mem_mb":32.8,"disk_size":"50.1M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":4.9,"import_time_s":2.05,"mem_mb":33,"disk_size":"75M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2,"mem_mb":32.8,"disk_size":"51M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":1.53,"mem_mb":28.3,"disk_size":"55.5M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.36,"mem_mb":28.2,"disk_size":"55.4M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":5,"import_time_s":1.18,"mem_mb":28.3,"disk_size":"56M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.13,"mem_mb":28.2,"disk_size":"56M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}