Install Graphviz on Windows 11

A requirement while drawing model on Keras

Sparisoma Viridi
4 min readMay 10, 2024

Keras provides model plotting utilities, which requires Graphviz softaware installed and also graphviz Python package.

Above is the hint while executing Keras code, lead to the requirement of graphviz, and also pydot (not shown).

Download installer

Visit https://graphviz.org/download/ and choose the latest version windows_10_cmake_Release_graphviz-install-11.0.0-win64.exe.

https://gitlab.com/graphviz/graphviz/-/releases

Latest version is released on 28 Apr 2024, less than two weeks a go.

Perform installation

A simplified procedure for installation on Widows is available, which was still for version 2.44.1. Hopefully, it is still the same about general consensus is that it’s a false positive on Potential Trojan, since the post is four years a go.

Click More info.

Click Run anyway and click Yes.

Click Next.

Scroll down the agreement.

Click I Agree.

Check Add Graphviz to the system PATH for current user and click Next.

Click Next.

Add 11.0.0 to differ it from other version and click Install.

Click Finish.

Check installation

Navigate to C:\Program Files\Graphviz, then click bin folder.

Some applications are installed on C:\Program Files\Graphviz\bin folder.

It is also already listed in system PATH.

Python packages

Two packages are required to install, first is pydot from https://pypi.org/project/pydot/

(tf) M:\py-jupyter-nb>pip install pydot
Collecting pydot
Downloading pydot-2.0.0-py3-none-any.whl.metadata (9.6 kB)
Requirement already satisfied: pyparsing>=3 in v:\tf\lib\site-packages (from pydot) (3.1.2)
Downloading pydot-2.0.0-py3-none-any.whl (22 kB)
Installing collected packages: pydot
Successfully installed pydot-2.0.0

(tf) M:\py-jupyter-nb>

and the second is graphviz from https://pypi.org/project/graphviz/

(tf) M:\py-jupyter-nb>pip install graphviz
Collecting graphviz
Downloading graphviz-0.20.3-py3-none-any.whl.metadata (12 kB)
Downloading graphviz-0.20.3-py3-none-any.whl (47 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 47.1/47.1 kB 1.2 MB/s eta 0:00:00
Installing collected packages: graphviz
Successfully installed graphviz-0.20.3

(tf) M:\py-jupyter-nb>

where both can be installed using pip as already shown.

Result

Below is the result

of following codes

import numpy as np
import tensorflow as tf
from tensorflow.keras import layers
import keras
from keras import ops

# create input, two features, four rows
l = [ [1, 1], [1, 2], [2, 1], [2, 2] ]
x = ops.array(l)

model = tf.keras.Sequential([
layers.Dense(128, activation="sigmoid", name="Layer 1"),
layers.Dense(128, activation="relu", name="Layer 2"),
layers.Dense(10, activation="softmax", name="Layer 3")
])

y = model(x)
print(x)

dot_img_file = 'model_1.png'
keras.utils.plot_model(
model,
to_file=dot_img_file,
show_shapes=True,
show_dtype=True,
show_layer_names=True,
rankdir="TB",
show_layer_activations=True,
expand_nested=True,
show_trainable=True
)

It produces the plot as model_1.png file.

Notes

  • If necessary the requirements.txt is available on previous story, but still without additional packages from this story
    graphviz==0.20.3
    pydot==2.0.0
  • Jupyter Notebook tf_keras_plot.ipynb is available on GitHub.

--

--