From 99b670fc901bbb89d9a676371fc3cd2a2549d8d3 2017-12-20 00:21:10 From: Matthias Bussonnier Date: 2017-12-20 00:21:10 Subject: [PATCH] Backport PR #10634: fix of display() instantiates a shell in pure Python #10617 --- diff --git a/IPython/core/display.py b/IPython/core/display.py index 685bbf6..5c82a57 100644 --- a/IPython/core/display.py +++ b/IPython/core/display.py @@ -277,6 +277,13 @@ def display(*objs, **kwargs): from IPython.display import display """ + from IPython.core.interactiveshell import InteractiveShell + + if not InteractiveShell.initialized(): + # Directly print objects. + print(*objs) + return + raw = kwargs.pop('raw', False) include = kwargs.pop('include', None) exclude = kwargs.pop('exclude', None) @@ -294,8 +301,6 @@ def display(*objs, **kwargs): if transient: kwargs['transient'] = transient - from IPython.core.interactiveshell import InteractiveShell - if not raw: format = InteractiveShell.instance().display_formatter.format