From 04703d0d06dbc153014b538171275013db75f9c1 Mon Sep 17 00:00:00 2001
From: Christopher Degawa <ccom@randomderp.com>
Date: Tue, 4 Mar 2025 00:32:12 -0600
Subject: [PATCH] displacy: fix import path for ipython 9.0.1

Signed-off-by: Christopher Degawa <ccom@randomderp.com>
---
 spacy/displacy/__init__.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/spacy/displacy/__init__.py b/spacy/displacy/__init__.py
index bde2d04fe..cfee47096 100644
--- a/spacy/displacy/__init__.py
+++ b/spacy/displacy/__init__.py
@@ -66,7 +66,12 @@ 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:
+            # import path was changed in IPython 8.0.0 43a01a21101ea65dbd52cf760c1e4f149bfab588
+            # and the path shim was finally removed in 9.0.1 8a0533f31abcc4cb4341858bdeee86e2061c4fd9
+            from IPython.display import HTML, display
+        except ImportError:
+            from IPython.core.display import HTML, display
 
         return display(HTML('<span class="tex2jax_ignore">{}</span>'.format(html)))
     return html