Skip to content

Commit 79c1c9d

Browse files
fix: fix import for environments with no IPython installed (#1725)
* fix: fix import for environments with no IPython installed * fix(linting): code formatting --------- Co-authored-by: Azory YData Bot <azory@ydata.ai>
1 parent 9083053 commit 79c1c9d

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/ydata_profiling/utils/information.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
References and information regarding ydata-profiling and ydata-sdk
33
"""
4-
from IPython.display import HTML, display
4+
import importlib.util
55

66
_displayed_banner = False
77

@@ -12,15 +12,20 @@
1212

1313
def in_jupyter_notebook() -> bool:
1414
"""Check if the code is running inside a Jupyter Notebook"""
15-
from IPython import get_ipython
15+
if importlib.util.find_spec("IPython") is not None:
16+
from IPython import get_ipython
1617

17-
isiPython = not get_ipython() is None
18+
isiPython = not get_ipython() is None
19+
else:
20+
isiPython = False
1821
return isiPython
1922

2023

2124
def display_banner() -> None:
2225
global _displayed_banner
2326
if in_jupyter_notebook() and not _displayed_banner:
27+
from IPython.display import HTML, display
28+
2429
banner_html = f"""
2530
<div>
2631
<ins><a href="{link}">{title}</a></ins>

0 commit comments

Comments
 (0)