Installing Graphviz on Linux

Introduction:<span>Graphviz</span> is an open-source graph visualization software developed by AT&T Labs. It uses the DOT language to describe graphs and generates graphical representations of these graphs. Graphviz can create structured diagrams such as state machines, flowcharts, network diagrams, circuit diagrams, etc., which can be used for various purposes including documentation, testing, and database modeling.

1. Features of Graphviz
  • <span>Cross-platform</span>: Graphviz can run on various operating systems, including Linux, Windows, and macOS.
  • <span>Multiple graph layouts</span>: Graphviz provides various graph layout algorithms, including hierarchical layout, circular layout, tree layout, etc.
  • <span>Diverse output formats</span>: Graphviz supports multiple output formats such as PNG, JPEG, SVG, PDF, etc.
  • <span>Interactive viewer</span>: Graphviz comes with an interactive viewer that allows you to view and zoom in on graphs.
  • <span>Scripts and command-line tools</span>: Graphviz provides command-line tools that can automate graph generation through scripts.
2. Installing Graphviz

The basic steps to install Graphviz are as follows:

  • For Debian-based systems (like Ubuntu):
sudo apt-get update
sudo apt-get install graphviz graphviz-dev
  • For Red Hat-based systems (like Fedora):
sudo dnf install graphviz graphviz-devel
  • If your system prompts that the <span>dnf</span> command is not found, you can try using <span>yum</span> instead, or reinstall <span>dnf</span>:
sudo yum install dnf
  • Verify the installation by checking the version information
dot -V
  • Using Graphviz in Python
pip install pygraphviz
3. Issues Related to Graphviz

<span>pygraphviz</span> requires the Graphviz binaries to be available in the system path. If you encounter the error “GraphViz’s executables not found” after installing <span>pygraphviz</span>, you may need to check if Graphviz is correctly installed and whether its executable path has been added to the system’s <span>PATH</span> environment variable.

  • Configuring the environment variable:

After installing Graphviz, ensure that the path to the Graphviz executables is added to the system’s <span>PATH</span> environment variable. You can do this by editing the <span>~/.bashrc</span> or <span>~/.profile</span> file to add the following line:

export PATH=$PATH:/path/to/graphviz/bin

Replace <span>/path/to/graphviz/bin</span> with your Graphviz installation path. After that, run <span>source ~/.bashrc</span> or log in again to apply the changes. After changing the environment variable, restart your IDE or terminal to ensure the new environment variable takes effect.

<span>Note:</span> For other versions of Graphviz, download from the following link: Graphviz official website

Leave a Comment