"dot.exe" not found in path. Pydot on Python (Windows 7)

Question:

I’m having trouble running Python’s pydot on Windows 7.

I installed pydot with: conda install -c rmg pydot=1.2.2

I have graphviz installed under ../Program Files (x86)/Graphviz2.38/

When I run the following script I get an error saying

"dot.exe" not found in path
import pydot
graph = pydot.Dot(graph_type='digraph')
node_a = pydot.Node("Node A", style="filled", fillcolor="red")
node_b = pydot.Node("Node B", style="filled", fillcolor="green")
node_c = pydot.Node("Node C", style="filled", fillcolor="#0000ff")
node_d = pydot.Node("Node D", style="filled", fillcolor="#976856")
graph.add_node(node_a)
graph.add_node(node_b)
graph.add_node(node_c)
graph.add_node(node_d)
graph.add_edge(pydot.Edge(node_a, node_b))
graph.add_edge(pydot.Edge(node_b, node_c))
graph.add_edge(pydot.Edge(node_c, node_d))
graph.add_edge(pydot.Edge(node_d, node_a, label="and back we go again", labelfontcolor="#009933", fontsize="10.0", color="blue"))
graph.write_png('example2_graph.png')

Exception: "dot.exe" not found in path.

I have tried this solution: Permanently adding a file path to sys.path in Python, by adding the my-paths.pth file with a line pointing to
../Graphiv2.38/bin/ where the dot.exe file is located. But I still get the error.

What else can I try?

Asked By: Dubraven

||

Answers:

I followed the instructions given in this blog.

Then I installed graphviz from here and added C:Program Files (x86)Graphviz2.38bin to PATH.

Next I did:

conda install pydot-ng 

And finally in my notebook I added the two lines below.

import os
os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'

Using django-extensions to generate the model graph for your Django application, I did this and it worked:

pip install django-extensions
pip install pyparsing
pip install graphviz
pip install pydot
conda install graphviz

Add django-extensions to you INSTALLED_APPS and then add C:Program FilesAnaconda3pkgsgraphviz-2.38.0-4Librarybingraphviz to my system path variable.
Then finally and normally:

python manage.py graph_models -a -g -o pic.png
Answered By: Gret

I was having trouble with this and found out that if you’re using the Visual Studio Code integrated command line then you should make sure to restart Visual Studio Code (you might need to only restart the command line) otherwise the PATH changes won’t take place…

Answered By: ToxicGLaDOS

Type conda install pydot graphviz in cmd, and then add the executables location directory C:Anaconda3pkgsgraphviz-2.38-hfd603c8_2Librarybingraphviz to your system path variable. That works!

Answered By: jmir

Don’t use the following command if you are on Python 3:

conda install pydot-ng 

This will take your installation to Python 2.7

Use instead

conda install graphviz
Answered By: Rajneesh Aggarwal

Other solutions didn’t work for me, and I figured out pydot tried to run a hardcoded dot.bat so I just created dot.bat wrapper nearby dot.exe and it worked:

@echo off
dot %*
Answered By: Rabash

In this kind of cases, when resources are not found by programs on your system, follow these quick steps:

  • Run a simple command prompt, type and execute the needed command (can be ‘dot.exe’)
  • If yes, your system is nicely configured and perhaps due to a hard configured way in your code, executables are not found (need a specific location for files to be found for instance: program check for C:Program FilesAnaconda3pkgsgraphviz and you put binaries in C:Program Filesgraphviz).
  • If no, you need to add it manually. In environment variable add the directory that contains the binaries (for instance ‘my_locationgraphvizbin’). If you need it for whole users of the computer, put it in the system ‘Path’ (need to disconnect the users accounts to be considered), else in the user ‘Path’ (need to reopen the needed program). Then check it by re-opening a command prompt and typing the command.

If it’s not working… you mistyped something =)

Some advices: Rapid Environment Editor is pretty cool for configuring windows environment variables 😉

Have a nice day!

Answered By: Romain Cendre

On Ubuntu 18.04 installing the binaries with sudo apt-get install graphviz led to dot being placed under /usr/bin/dot (it might go to /usr/local/bin/dot per their installation guide).
After doing:

pip3 install pydot-ng

and adding the following lines (similar to @Ernest’s answer in Linux) to the script it worked:

import os
os.environ["PATH"] += os.pathsep + "/usr/bin/dot"
Answered By: Farzad Vertigo

I’ve had some very bad experiences with conda, so avoid the mess it causes at all cost.

Fortunately every answer here is using conda unnecessarily. You can simply install this package with pip install pydot then after adding Graphviz to your path as described in the accepted answer, this error is resolved. (Windows)

Answered By: Recessive
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.