Graphviz not running in jupyter notebook python = 3.6?
Asked Answered
M

5

5

I am trying to run graphviz to view dot file on jupyter notebook in have imported path to dot.exe path.

G:\anaconda3\envs\tensorflowgpu\Library\bin\graphviz G:\anaconda3\envs\tensorflowgpu\Library\bin\graphviz\dot.exe

I am trying to run this code:

with open("tree1.dot") as f:
dot_graph = f.read()
graphviz.Source(dot_graph)

OR

graphviz.Source("tree1.dot") .view() 

It is giving:

failed to execute ['dot', '-Tsvg'], make sure the Graphviz executables are on your systems' PATH

Please tell me any way to fix this or any other way to View dot file on jupyter notebook i am running python 3.6 on jupter notebook

Meridional answered 12/9, 2017 at 17:46 Comment(1)
I solved this problem on debian by installing graphviz (not just pip install graphviz, but the actual executable which is available separately). Not sure how to solve it on Windows though...Doley
I
13

I have been having a similar issue (different execution - but both have the same errors in Jupyter) and was able to resolve it this way:

First I uninstalled the graphviz package I had originally installed via the Anaconda prompt.

conda remove graphviz

I found in this issue thread to use the below command to install the graphviz package. Appending graphviz with python- downloads the package in lib/site-packages

conda install python-graphviz

I restarted Jupyter Notebook in order to find dot.exe since I couldn't get it to find it in my running notebook after installing the package.

I hope this helps!

Ingham answered 10/4, 2018 at 22:0 Comment(0)
R
2

if you code doesn´t work, you can use this.

import graphviz
from IPython.display import display
with open("tree1.dot") as f:
dot_graph = f.read()
display(graphviz.Source(dot_graph))
Rogers answered 15/1, 2019 at 11:58 Comment(0)
E
1

the following worked for me (removal in Jupyter via 'conda remove graphviz' didn't work):

go to Anaconda Navigator Console:

-->Environments--> Search for graphviz --> deinstall

-->Environments --> install python-graphviz

Embowed answered 14/11, 2021 at 21:58 Comment(0)
R
0

Reinstall graphviz

conda remove graphviz 
conda install python-graphviz
graphviz.Source(dot_graph).view()

after you will have a small window where you have to choose where you want see your decision tree

Rogers answered 15/1, 2019 at 11:45 Comment(0)
O
0

Building on the other answers,

I was having this problem with a new instance of Jupyter Notebook v4.0.7 hosted on the jupyter/minimal-notebook docker container.

I was able to install graphviz by running this command in a cell:

!conda install -y python-graphviz

Otherdirected answered 29/6 at 13:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.