From 574c59f44beffcc75b2897318a527fe3fe72e869 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Mar 2020 12:48:29 -0500 Subject: [PATCH 1/2] tried to fix default renderer for ipython terminal --- packages/python/plotly/plotly/io/_renderers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/python/plotly/plotly/io/_renderers.py b/packages/python/plotly/plotly/io/_renderers.py index 2341339d028..36570839701 100644 --- a/packages/python/plotly/plotly/io/_renderers.py +++ b/packages/python/plotly/plotly/io/_renderers.py @@ -452,7 +452,7 @@ def show(fig, renderer=None, validate=True, **kwargs): ) default_renderer = env_renderer -elif ipython and ipython.get_ipython(): +elif ipython and ipython.get_ipython() and not (ipython.get_ipython().__class__.__name__ == 'TerminalInteractiveShell'): # Try to detect environment so that we can enable a useful # default renderer if not default_renderer: From bf62f47cff8dfbf0403ca59a9294a195e807fb9f Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 6 Mar 2020 14:03:50 -0500 Subject: [PATCH 2/2] refactoring --- packages/python/plotly/plotly/io/_renderers.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/python/plotly/plotly/io/_renderers.py b/packages/python/plotly/plotly/io/_renderers.py index 36570839701..5277c9efec7 100644 --- a/packages/python/plotly/plotly/io/_renderers.py +++ b/packages/python/plotly/plotly/io/_renderers.py @@ -452,7 +452,7 @@ def show(fig, renderer=None, validate=True, **kwargs): ) default_renderer = env_renderer -elif ipython and ipython.get_ipython() and not (ipython.get_ipython().__class__.__name__ == 'TerminalInteractiveShell'): +elif ipython and ipython.get_ipython(): # Try to detect environment so that we can enable a useful # default renderer if not default_renderer: @@ -497,6 +497,12 @@ def show(fig, renderer=None, validate=True, **kwargs): # orca not found pass + # Check if we're running in ipython terminal + if not default_renderer and ( + ipython.get_ipython().__class__.__name__ == "TerminalInteractiveShell" + ): + default_renderer = "browser" + # Fallback to renderer combination that will work automatically # in the classic notebook (offline), jupyterlab, nteract, vscode, and # nbconvert HTML export.