spaCy icon indicating copy to clipboard operation
spaCy copied to clipboard

Fix: Update display import for compatibility with latest IPython Fixes: #13763

Open rnihesh opened this issue 8 months ago • 10 comments

Fix: Update display import for compatibility with latest IPython


Description

This PR updates the import statement in displacy.render() to fix an ImportError caused by breaking changes in IPython 9+.

Replaced:

from IPython.core.display import HTML, display

With:

from IPython.display import HTML, display

The display function is no longer available in IPython.core.display in IPython 9 and above. This change ensures displacy.render() works correctly in Jupyter and notebook environments using newer versions of IPython.

Tested in:

  • Python 3.12.9 (venv)
  • IPython 9.0.2
  • JupyterLab
  • Confirmed displacy.render() now works without error.

Types of change

  • [x] Bug fix

Checklist

  • [x] I confirm that I have the right to submit this contribution under the project's MIT license.
  • [x] I ran the tests, and all new and existing tests passed.
  • [x] My changes don't require a change to the documentation, or if they do, I've added all required information.

Fixes: #13763

rnihesh avatar Apr 04 '25 17:04 rnihesh

also ran into this issue, was about to submit my own PR

majorgilles avatar Apr 06 '25 10:04 majorgilles

Thanks a lot and sorry for only getting to this now!

Just wondering if we should include a try/except here for backwards compatibility, even though it's not very pretty. Because I wouldn't want users on older IPython versions to run into problems going forward. This is probably the one thing I would add and then we can ship this (happy to do it before we release or you can also make an update) 🙂

ines avatar May 12 '25 05:05 ines

Yup working on that

rnihesh avatar May 12 '25 11:05 rnihesh

done fixed

rnihesh avatar May 12 '25 11:05 rnihesh

@ines ping...

celestinoxp avatar Jun 15 '25 07:06 celestinoxp

this is very annoying especially when working with prodigy :/ had to patch version which prodigy pulls etc

wildfluss avatar Jun 23 '25 11:06 wildfluss

Temporary solution until this is merged:

$ pip install -U "ipython<9"

it176131 avatar Sep 02 '25 18:09 it176131

@honnibal or someone from spacy team please merge this. Thank you.

ondraz avatar Oct 13 '25 13:10 ondraz

please merge this @ines @honnibal

rnihesh avatar Oct 13 '25 16:10 rnihesh

Also if you have issues with IPython like that, feel free to ping me, I can always re-add the old imports for a few version if it breaks the world.

Carreau avatar Oct 14 '25 16:10 Carreau