From 674b29efb4068c821fb8982acce00577a6fcbcd7 Mon Sep 17 00:00:00 2001 From: Marco Paolini Date: Tue, 13 Aug 2019 21:41:13 +0100 Subject: [PATCH] Avoid crash in iframe renderers when running outside iPython --- packages/python/plotly/plotly/io/_base_renderers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/python/plotly/plotly/io/_base_renderers.py b/packages/python/plotly/plotly/io/_base_renderers.py index bbb5fabeb1b..64760d4728a 100644 --- a/packages/python/plotly/plotly/io/_base_renderers.py +++ b/packages/python/plotly/plotly/io/_base_renderers.py @@ -598,8 +598,8 @@ def to_mimebundle(self, fig_dict): return {"text/html": iframe_html} def build_filename(self): - ip = IPython.get_ipython() - cell_number = list(ip.history_manager.get_tail(1))[0][1] + 1 + ip = IPython.get_ipython() if IPython else None + cell_number = list(ip.history_manager.get_tail(1))[0][1] + 1 if ip else 0 filename = "{dirname}/figure_{cell_number}.html".format( dirname=self.html_directory, cell_number=cell_number )