Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`pydot` failed to call GraphViz.Please install GraphViz and ensure that its executables are in the $PATH

My jupyter server is running in a gcp deep learning vm.

I'm trying to print the model in a Jupyter notebook cell.

import os, sys
from utils.models.alexnet import alexnet
from keras.utils.vis_utils import plot_model
from keras.optimizers import SGD

model = alexnet(len(class_names))
model.summary()
plot_model(model, to_file="alexnet_model.png", show_shapes=True)

I get this error

`pydot` failed to call GraphViz.Please install GraphViz ([https://www.graphviz.org/](https://www.graphviz.org/)) and ensure that its executables are in the $PATH.

I have correctly installed Graphviz in my machine with

apt-get install graphviz

stat /usr/bin/dot
  File: /usr/bin/dot
  Size: 10568       Blocks: 24         IO Block: 4096   regular file
Device: 801h/2049d  Inode: 142872      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-02-10 11:48:19.416617639 +0000
Modify: 2017-02-19 10:32:17.000000000 +0000
Change: 2019-12-13 01:47:41.084977709 +0000

The python packages pydot, pydot-ng, pydotplus are also installed.

This is my path variable

echo $PATH
/usr/local/cuda/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

/user/bin is included here.

EDIT

When executed in a jupyter notebook shell.

print(os.environ["PATH"])

/usr/local/cuda/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

Another wierd thing

I have a simple image dataset with 3 classes and altogether around 2000 images. In my jupyter notebook I first process and load the images into memory. Creating the model and printing it comes next. With the simple dataset it works without error. This happens when I work with large datasets.

like image 824
Enzio Avatar asked Feb 10 '20 13:02

Enzio


2 Answers

I was also getting the same thing so i install conda install python-graphviz after conda install pydot

like image 77
Prerna Verma Avatar answered Sep 28 '22 18:09

Prerna Verma


I have the same problem, I solved it by following the Answer of Prerna Verma. By the way, there are three steps for using graphviz in Linux Envs:

  1. sudo apt-get install graphviz (download and install graphviz, if you are a Windows User)

  2. conda install pydot

  3. conda install python-graphviz

then, you can use it!

like image 25
chenn Avatar answered Sep 28 '22 16:09

chenn