Question: How to correctly execute 'dot' from Graphviz in Spyder (Anaconda) in macOS?
Context: I know this topic has been already addressed in other posts:
- How to use Graphviz with Anaconda/Spyder?
- (Python) ValueError: Program dot not found in path
- Exception: “dot” not found in path in python on mac
But I have tried all the recommendations on these posts and I still get the errors:
Exception: “dot” not found in path in python on mac
FileNotFoundError: [Errno 2] No such file or directory: 'dot'
ExecutableNotFound: failed to execute ['dot', '-Kdot', '-Tpdf', '-O', 'FileName'], make sure the Graphviz executables are on your systems' PATH
I have already installed Graphviz, and as you can see below, dot is working:
Above can be seenn that by typing:
dot -V
It returns the version I have installed. As well as when typing:
which dot
It returns the location of the file (i.e., /usr/local/bin). I have tried several things with this path.
- Add it to the path in Spyder:
- I added to the main system PATH:
- And I even run a script in Python trying to add the path from the code (I have tried it with and without 'dot' at the end of the path):
None of the above solutions worked for me. If anyone could give me some insights to solve this problem, I would really appreciate it.
As an example, you can try the code below, which is the one that gives me the error (source):
import graphviz
dot = graphviz.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')
dot.render('FileName', view=True)