title: Installing Graphviz for use with Python 3 on Windows 10
body: <p>So I've had Python 3.6 on my Windows 10 computer for a while now, and today I just downloaded and installed the <code>graphviz 0.8.2</code> (<a href="https://pypi.python.org/pypi/graphviz" rel="noreferrer">https://pypi.python.org/pypi/graphviz</a>) package via the admin commandline with:</p>
  
  <p><code>pip3 install graphviz</code></p>
  
  <p>It was only after this point that I downloaded the Graphviz 2.38 MSI installer file and installed the program at:</p>
  
  <p><code>C:\Program Files (x86)\Graphviz2.38</code></p>
  
  <p>So then I tried to run this simple Python program:</p>
  
  <pre><code>from graphviz import Digraph
  
  dot = Digraph(comment="The round table")
  dot.node('A', 'King Arthur')
  dot.node('B', 'Sir Bedevere the Wise')
  dot.node('L', 'Sir Lancelot the Brave')
  dot.render('round-table.gv', view=True)
  </code></pre>
  
  <p>But unfortunately, I received the following error when I try to run my Python program from commandline:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Program Files\Python36\lib\site-packages\graphviz\backend.py", line 124, in render
      subprocess.check_call(args, startupinfo=STARTUPINFO, stderr=stderr)
    File "C:\Program Files\Python36\lib\subprocess.py", line 286, in check_call
      retcode = call(*popenargs, **kwargs)
    File "C:\Program Files\Python36\lib\subprocess.py", line 267, in call
      with Popen(*popenargs, **kwargs) as p:
    File "C:\Program Files\Python36\lib\subprocess.py", line 709, in __init__
      restore_signals, start_new_session)
    File "C:\Program Files\Python36\lib\subprocess.py", line 997, in _execute_child
      startupinfo)
  FileNotFoundError: [WinError 2] The system cannot find the file specified
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "D:\foldername\testing.py", line 11, in &lt;module&gt;
      dot.render('round-table.gv', view=True)
    File "C:\Program Files\Python36\lib\site-packages\graphviz\files.py", line 176, in render
      rendered = backend.render(self._engine, self._format, filepath)
    File "C:\Program Files\Python36\lib\site-packages\graphviz\backend.py", line 127, in render
      raise ExecutableNotFound(args)
  graphviz.backend.ExecutableNotFound: failed to execute ['dot', '-Tpdf', '-O', 'round-table.gv'], make sure the Graphviz executables are on your systems' PATH
  </code></pre>
  
  <p>Notice how what I've asked seems VERY similar to this question asked here:
  <a href="https://stackoverflow.com/questions/35064304/runtimeerror-make-sure-the-graphviz-executables-are-on-your-systems-path-aft">&quot;RuntimeError: Make sure the Graphviz executables are on your system&#39;s path&quot; after installing Graphviz 2.38</a></p>
  
  <p>But for some reason, adding those paths (suggested in the solutions at the link above) to the system variables isn't working, and I don't know why!  I tried restarting the computer after adding the paths as well, still to no success.  See the image below:</p>
  
  <p><a href="https://i.stack.imgur.com/VYRrK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VYRrK.png" alt="enter image description here"></a></p>
  
  <p>Although the other suggested solution, which was to add these few lines in front of my Python code, <em>did</em> work:</p>
  
  <pre><code>import os
  os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'
  </code></pre>
  
  <p>But here's the issue: I don't understand why adding to the environment variables didn't work, and this is my primary concern.  <strong>So my question is this: why did adding those lines of code in front of the Python script work but changing the environment variables didn't?</strong>  What do I need to do to get my script to run without adding those lines of code in front?</p>