Question: I want to plot the tree generated by DEAP using pygraphviz. I tried to follow the example in this [DEAP document](https://deap.readthedocs.io/en/master/tutorials/advanced/gp.html), but got the following error:

```
Traceback (most recent call last):
  File "<input>", line 24, in <module>
  File "C:\Users\xxyao\program\anaconda\envs\rf\lib\site-packages\pygraphviz\agraph.py", line 1399, in layout
    data = self._run_prog(prog, ' '.join([args, "-T", fmt]))
  File "C:\Users\xxyao\program\anaconda\envs\rf\lib\site-packages\pygraphviz\agraph.py", line 1364, in _run_prog
    raise IOError(b"".join(errors).decode(self.encoding))
OSError: Format: "dot" not recognized. Use one of:

```

It seems like should be some words after the `Use one of:` but there is not. My environment is `Python==3.6`,`graphviz==3.41`,`pygraphviz==1.5`.The `graphviz`and `pygraphviz` are installed via `conda`.

By the way, I tried the following method: 

1. install graphviz and add `C:\Program Files (x86)\Graphviz2.38\bin` to system environment.
2. `conda install pydot`, `conda install pydot-ng`

but it still doesn't work.

Further infomation: Other layout provided by `pygraphviz` such as `neato fdp twopi` works well. Only the `dot` doesn't work!

Answer: 
I made something that may be considered a bit of cheating, but hope it helps.
First, agraph.py takes into account the position of the directory so you may want to put the working dot ahead of the others

```
import os
os.environ["PATH"] = "C:\\Program Files\\Graphviz\\bin" + os.pathsep + os.getenv("PATH")

```

Then I changed the agraph.py file, which it may be located at "C:\Users\xxyao\program\anaconda\envs\rf\lib\site-packages\pygraphviz\agraph.py", line 1561 from

```
if os.name == "nt":

```

into

```
if os.name == "nt" or os.name == "dot":

```
Follow @Saul answer is worked for me. I think the root cause may be the `agraph.py` allow only limited PATH environment variable so even you add `C:\\Program Files\\Graphviz\\bin` still not work.

But be careful, I suggest the solution for this way should be secured by below

```
GVZPath = "C:\\Program Files\\Graphviz\\bin"
if (os.getenv("PATH").find(GVZPath))!=0:
    os.environ["PATH"] = "C:\\Program Files\\Graphviz\\bin" + os.pathsep + os.getenv("PATH")

```