Fix: Update display import for compatibility with latest IPython Fixes: #13763
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
also ran into this issue, was about to submit my own PR
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) 🙂
Yup working on that
done fixed
@ines ping...
this is very annoying especially when working with prodigy :/ had to patch version which prodigy pulls etc
Temporary solution until this is merged:
$ pip install -U "ipython<9"
@honnibal or someone from spacy team please merge this. Thank you.
please merge this @ines @honnibal
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.