Skip to content

Commit 01a78d3

Browse files
mpaolinijonmmease
authored andcommitted
Avoid crash in iframe renderers when running outside iPython (#1723)
1 parent 6eb94f0 commit 01a78d3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: packages/python/plotly/plotly/io/_base_renderers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,8 @@ def to_mimebundle(self, fig_dict):
598598
return {"text/html": iframe_html}
599599

600600
def build_filename(self):
601-
ip = IPython.get_ipython()
602-
cell_number = list(ip.history_manager.get_tail(1))[0][1] + 1
601+
ip = IPython.get_ipython() if IPython else None
602+
cell_number = list(ip.history_manager.get_tail(1))[0][1] + 1 if ip else 0
603603
filename = "{dirname}/figure_{cell_number}.html".format(
604604
dirname=self.html_directory, cell_number=cell_number
605605
)

0 commit comments

Comments
 (0)