-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Open
Description
Problem
displaycy.render
seems to be broken when used in Jupyter Mode with a current ipython version. The method yields an ImportError: cannot import name 'display' from 'IPython.core.display'
when in Jupyter Mode.
How to reproduce the behaviour
Run the following example code inside a Jupyter Notebook:
import spacy
from spacy import displacy
nlp = spacy.load("en_core_web_sm")
doc = nlp("This is a sentence.")
displacy.render(doc, style="dep", jupyter=True)
This yields the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[1], line 5
3 nlp = spacy.load("en_core_web_sm")
4 doc = nlp("This is a sentence.")
----> 5 displacy.render(doc, style="dep", jupyter=True)
File ~/abc/.venv/lib/python3.12/site-packages/spacy/displacy/__init__.py:69, in render(docs, style, page, minify, jupyter, options, manual)
65 html = RENDER_WRAPPER(html)
66 if jupyter or (jupyter is None and is_in_jupyter()):
67 # return HTML rendered by IPython display()
68 # See #4840 for details on span wrapper to disable mathjax
---> 69 from IPython.core.display import HTML, display
71 return display(HTML('<span class="tex2jax_ignore">{}</span>'.format(html)))
72 return html
ImportError: cannot import name 'display' from 'IPython.core.display' (/home/xyz/abc/.venv/lib/python3.12/site-packages/IPython/core/display.py)
Your Environment
- spaCy version: 3.8.7
- Platform: Linux-6.8.0-79-generic-x86_64-with-glibc2.39
- Python version: 3.12.3
- Pipelines: en_core_web_sm (3.8.0)
My Workaround
Downgrade ipython to 7.23.1:
pip install ipython==7.23.1
Metadata
Metadata
Assignees
Labels
No labels