diff --git a/docs/release-notes/1.8.0.rst b/docs/release-notes/1.8.0.rst index ebeff58b4b..4c136115e2 100644 --- a/docs/release-notes/1.8.0.rst +++ b/docs/release-notes/1.8.0.rst @@ -25,6 +25,7 @@ .. rubric:: Bug fixes - Fix :func:`scanpy.pl.paga_path` `TypeError` with recent versions of anndata :pr:`1047` :smaller:`P Angerer` +- Fix detection of whether IPython is running :pr:`1844` :smaller:`I Virshup` .. rubric:: Deprecations diff --git a/scanpy/_settings.py b/scanpy/_settings.py index e217b36083..f694693b13 100644 --- a/scanpy/_settings.py +++ b/scanpy/_settings.py @@ -470,8 +470,9 @@ def set_figure_params( @staticmethod def _is_run_from_ipython(): """Determines whether we're currently in IPython.""" - # https://stackoverflow.com/questions/40638507/testing-for-presence-of-ipython - return hasattr(__builtins__, "__IPYTHON__") + import builtins + + return getattr(builtins, "__IPYTHON__", False) def __str__(self) -> str: return '\n'.join(