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

I am having problems running Python pydot on Windows 7.

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

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

When I run the following script, I get an error

 "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 tried this solution: constantly add the path to the sys.path file in Python , adding the my-paths.pth with a line pointing to ../Graphiv2.38/bin/ where dot.exe dot.exe . But I still get the error.

What else can I try?

+21
source share
7 answers

I followed the instructions given on this blog .

Then I installed Graphviz from here and added C: \ Program Files (x86) \ Graphviz2.38 \ Bin to PATH .

Then I did:

 conda install pydot-ng 

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

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

Type conda install pydot graphviz in cmd, and then add the executable location directory C:\Anaconda3\pkgs\graphviz-2.38-hfd603c8_2\Library\bin\graphviz to the system path variable. It works!

+6
source

Using django extensions to generate a 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 Files\Anaconda3\pkgs\graphviz-2.38.0-4\Library\bin\graphviz to my system path variable. Then finally and fine:

 python manage.py graph_models -a -g -o pic.png 
+1
source

I had problems with this, and I found that if you use the integrated command line of Visual Studio code, then you should definitely restart the Visual Studio code (you may only need to restart the command line), otherwise PATH changes will not occur ...

+1
source

Do not use the following command if you are using Python 3:

 conda install pydot-ng 

This will transfer your installation to Python 2.7

Use instead

 conda install graphviz 
+1
source

Other solutions do not work for me, and I realized pydot tried to run the dot.bat , so I just created a dot.bat wrapper for the nearby dot.exe and it worked:

 @echo off dot %* 
+1
source

In such cases, when programs do not detect resources on your system, follow these quick steps:

  • Run a simple command line, enter and execute the desired command (maybe 'dot.exe')
  • If so, your system is configured correctly and, possibly, because of a hard-tuned method, no executable files were found in your code (you need to specify a specific location for the files, for example: checking the program for C: \ Program Files \ Anaconda3 \ pkgs \ and you put the binary files in C: \ Program Files \ graphviz).
  • If not, you need to add it manually. Add the directory containing the binaries to the environment variable (for example, "my_location \ graphviz \ bin"). If all users of the computer need it, place it in the system Path (you need to disable user accounts), and in the user Path (you need to re-open the desired program). Then test it by reopening the command line and entering the command.

If this does not work ... you sealed something =)

A few tips: The Rapid Environment Editor is pretty useful for setting up Windows environment variables;)

Have a nice day!

0
source

Source: https://habr.com/ru/post/1012373/


All Articles