From f767ab90cd909eaa34e8edddfdaf8f5dc5e9383b Mon Sep 17 00:00:00 2001 From: reonokiy Date: Fri, 22 Aug 2025 14:44:43 +0800 Subject: [PATCH] chore(ipython): import from `IPython.display` instead of `IPython.core.display` --- spacy/displacy/__init__.py | 2 +- website/docs/api/top-level.mdx | 2 +- website/docs/usage/visualizers.mdx | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spacy/displacy/__init__.py b/spacy/displacy/__init__.py index bde2d04fe..032c27ce7 100644 --- a/spacy/displacy/__init__.py +++ b/spacy/displacy/__init__.py @@ -66,7 +66,7 @@ def render( if jupyter or (jupyter is None and is_in_jupyter()): # return HTML rendered by IPython display() # See #4840 for details on span wrapper to disable mathjax - from IPython.core.display import HTML, display + from IPython.display import HTML, display return display(HTML('{}'.format(html))) return html diff --git a/website/docs/api/top-level.mdx b/website/docs/api/top-level.mdx index 340f10f77..cb4bd0a35 100644 --- a/website/docs/api/top-level.mdx +++ b/website/docs/api/top-level.mdx @@ -1452,7 +1452,7 @@ detecting the IPython kernel. Mainly used for the > ```python > html = "

Hello world!

" > if util.is_in_jupyter(): -> from IPython.core.display import display, HTML +> from IPython.display import display, HTML > display(HTML(html)) > ``` diff --git a/website/docs/usage/visualizers.mdx b/website/docs/usage/visualizers.mdx index 2905ba2bd..66d9af911 100644 --- a/website/docs/usage/visualizers.mdx +++ b/website/docs/usage/visualizers.mdx @@ -254,12 +254,12 @@ rendering if auto-detection fails. ![displaCy visualizer in a Jupyter notebook](/images/displacy_jupyter.jpg) -Internally, displaCy imports `display` and `HTML` from `IPython.core.display` +Internally, displaCy imports `display` and `HTML` from `IPython.display` and returns a Jupyter HTML object. If you were doing it manually, it'd look like this: ```python -from IPython.core.display import display, HTML +from IPython.display import display, HTML html = displacy.render(doc, style="dep") display(HTML(html))