vscode doesn't like displacy.render(sentence1, style="dep")
How to reproduce the behaviour
ImportError Traceback (most recent call last)
Cell In[44], line 2
1 from spacy import displacy
----> 2 displacy.render(sentence1, style="dep")
File c:\Users\kundeng\scoop\persist\mambaforge\envs\spacy\Lib\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' (c:\Users\xxx\scoop\persist\mambaforge\envs\spacy\Lib\site-packages\IPython\core\display.py)
Your Environment
- Operating System: Windows 11
- Python Version Used: python 3.12.10
- spaCy Version Used: 3.8.5
- Environment Information: Conda Mamaforge
Well actually I'm pretty sure it's because spacy relies on iPython 8.x, but what I have is 9.x.
@kundeng explicitly installing 8.x of iPython in my environment fixed it for me.
Thanks. Downgrading iPython to v8.x from v9 fixed the issue on Linux + Python 3.11.
The issue is in the import from IPython.core.display. In the new version it should be IPython.display. That does work for me
The issue is in the import from IPython.core.display. In the new version it should be IPython.display. That does work for me
import sys from IPython import display sys.modules['IPython.core.display'] = display
this fixed it for me, thanks!