title: macos: converting dot to png
body: <p>I've studied the solutions outlined here:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/5316206/converting-dot-to-png-in-python">Converting dot to png in python</a></li>
  </ul>
  
  <p>However, none of these solutions work for me. In particular, when I try the check_call method, I get the following error:</p>
  
  <pre><code>  File "/Users/anaconda/lib/python2.7/subprocess.py", line 1343, in _execute_child
  raise child_exception
    OSError: [Errno 2] No such file or directory
  </code></pre>
  
  <p>When I use pydot, I get this error: <code>(graph,)=pydot.graph_from_dot_data(dotfile.getvalue())
  TypeError: 'Dot' object is not iterable</code></p>
  
  <p>Here is some example code I found on one of the above posts that I've been testing:</p>
  
  <pre><code>from sklearn import tree  
  import pydot
  import StringIO
  from subprocess import check_call
  
  # Define training and target set for the classifier
  train = [[1,2,3],[2,5,1],[2,1,7]]
  target = [10,20,30]
  
  # Initialize Classifier. Random values are initialized with always the same random seed of value 0 
  # (allows reproducible results)
  dectree = tree.DecisionTreeClassifier(random_state=0)
  dectree.fit(train, target)
  
  # Test classifier with other, unknown feature vector
  test = [2,2,3]
  predicted = dectree.predict(test)
  
  dotfile = StringIO.StringIO()
  tree.export_graphviz(dectree, out_file=dotfile)
  check_call(['dot','-Tpng','InputFile.dot','-o','OutputFile.png'])
  
  
  (graph,)=pydot.graph_from_dot_data(dotfile.getvalue())
  graph.write_png("dtree.png")
  </code></pre>
  
  <p>Thanks in advance.</p>