Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graphviz's executables are not found (Python 3.4)

I am running Python3.4 on Windows 7. I am trying to use the Python interface for graphviz. This is a script I intend to run:

from graphviz import Digraph import pydotplus  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.edges(['AB', 'AL']) dot.edge('B', 'L', constraint='false')  print(dot.source) dot.render('test-output/round-table.gv', view=True) 

I get the following error at runtime:

RuntimeError: failed to execute ['dot', '-Tpdf', '-O', 'test-output/round-table.gv'], make sure the Graphviz executables are on your systems' path 

Now I am sure I have properly installed the correct dependencies. I first tried to set the correct environment variables. The graphviz executables are located at C:\Program Files (x86)\Graphviz2.37\bin so I went to the Environment Variables section. There are two sections there: User Variables and System Variables. Under System Variables I clicked on Path and then clicked Edit and added ;C:\Program Files (x86)\Graphviz2.37\bin to the end of the string and saved. This didn't clear the error.

Then, following the answer given here I uninstalled pydot (actually I use pydotplus here) and re-installed it again, but still no success.

I have been trying for hours to fix this and the whole PATH variable thing is just confusing and frustrating.

like image 201
Morteza R Avatar asked Feb 04 '15 02:02

Morteza R


People also ask

How do I add a graphviz to my path?

Graphviz on Windows In Advance settings, a dialogue box opens that shows the Environment Variables button. Click the button. Select the entry Path in the system variables section and add C:\Program Files (x86)\GraphvizX. XX\bin to the existing path.

What is Pydotplus in Python?

PyDotPlus is an improved version of the old pydot project that provides a Python Interface to Graphviz's Dot language.

How do I import graphviz?

It simply puts the graphviz files into your virtual env's Library/ directory. Look e.g. for dot.exe in the Library/bin/ directory. To install the graphviz Python package, you can use pip : conda install pip and pip install graphviz . Always prefer conda packages if they are available over pip packages.


2 Answers

I also had this problem on Ubuntu 16.04.

Fixed by running sudo apt-get install graphviz in addition to the pip install I had already performed.

like image 128
tom4everitt Avatar answered Oct 04 '22 20:10

tom4everitt


In my case (Win10, Anaconda3, Jupyter notebook) after "conda install graphviz" I have to add to the PATH: C:\Users\username\Anaconda3\Library\bin\graphviz

To modify PATH goto Control Panel > System and Security > System > Advanced System Settings > Environment Variables > Path > Edit > New

like image 38
Silvia Bakalova Avatar answered Oct 04 '22 20:10

Silvia Bakalova