Calysto / metakernel

Jupyter/IPython Kernel Tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

%%dot magic doesn't work with recent versions of pydot

jnahmias opened this issue · comments

Any version of pydot >= 1.2.0, has a new interface which returns a list of graphs. Here's a patch that assumes a single graph is returned:

--- dot_magic.py.orig   2019-06-25 02:23:18.000000000 +0000
+++ dot_magic.py        2019-07-28 03:51:25.405139828 +0000
@@ -22,7 +22,7 @@
             import pydot
         except:
             raise Exception("You need to install pydot")
-        graph = pydot.graph_from_dot_data(str(code))
+        (graph,) = pydot.graph_from_dot_data(str(code))
         svg = graph.create_svg()
         if hasattr(svg, "decode"):
             svg = svg.decode("utf-8")
@@ -45,7 +45,7 @@
             import pydot
         except:
             raise Exception("You need to install pydot")
-        graph = pydot.graph_from_dot_data(str(self.code))
+        (graph,) = pydot.graph_from_dot_data(str(self.code))
         svg = graph.create_svg()
         if hasattr(svg, "decode"):
             svg = svg.decode("utf-8")