Skip to content
Open
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: 4 additions & 1 deletion spacy/displacy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ 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
try:
from IPython.display import HTML, display
except ImportError:
from IPython.core.display import HTML, display
Copy link

@Carreau Carreau Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IPython maintainer here, the correct import has been from IPython.display import ... since 2012 (circa IPython 0.13), (or at least it should have been)

And in general you should avoid ImportError (it's unclear why, and use version numbers checking otherwise)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess your docs have been changed, when I raised this PR, I even saw the docs, specifying .core.display is to be used, can't get the link, but will add a reference here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THe docs are autogenerated, and it's not because an object is defined in IPython.core.display that it should be imported from there.

See how IPython/disaply.py defines

from IPython.core.display import * 

https://github.com/ipython/ipython/blob/rel-1.0.0/IPython/display.py#L15

Which (should) makes the .core unnecessary everywhere.


return display(HTML('<span class="tex2jax_ignore">{}</span>'.format(html)))
return html
Expand Down