Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to `dash` will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/).

## [UNRELEASED]

### Fixed
- [#4037](https://github.com/plotly/dash/pull/4037) Only load the IPython and Jupyter integration modules when Dash is imported inside IPython. Roughly halves `import dash` time in environments that have IPython installed.

## [4.5.0] - 2026-10-29

### Added
Expand Down
3 changes: 3 additions & 0 deletions dash/_jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
from werkzeug.serving import make_server

try:
if "IPython" not in sys.modules:
# Not inside IPython: skip the heavy imports, they double the cost of `import dash`.
raise ImportError
from IPython import get_ipython # type: ignore[attr-defined]
from IPython.display import IFrame, display, Javascript # type: ignore[import-not-found]
from IPython.core.display import HTML # type: ignore[import-not-found]
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/test_jupyter_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import subprocess
import sys

import pytest

pytest.importorskip("IPython")


def _run(*args):
result = subprocess.run(
[sys.executable, *args], capture_output=True, text=True, check=False
)
assert result.returncode == 0, result.stderr


def test_import_dash_does_not_load_ipython():
_run("-c", "import dash, sys; assert 'IPython' not in sys.modules")


def test_jupyter_support_loads_inside_ipython():
_run(
"-m",
"IPython",
"-c",
"from dash import _jupyter; "
"assert _jupyter._dep_installed and _jupyter.jupyter_dash.in_ipython",
)
Loading