Pygraphviz Installation in Windows

Savleen
3 min readApr 7, 2021

--

Persistence can change failure into extraordinary achievement

Understanding pygraphviz

The pygraphviz library is used to obtain the graph layout. Pygraphviz is partly integrated into networkx and uses AGraph for graph representation.The resulting image of the graph can be exported in the notebook using the IMAGE class to encapsulate it.

While directly importing pygraphviz in Jupyter Notebook we may encounter the below Errors :

No Module named pygraphviz

import pygraphviz returns an error “ requires pygraphviz http://pygraphviz.github.io/

Command Error out with exit status 1(Failed building wheel for pygraphviz /

Collecting package metadata (current_repodata.json): done

Solving environment: failed with initial frozen solve. Retrying with flexible solve)

Let’s follow the below guidelines for pygraphviz installation :

Prerequisite to Pygraphviz is graphviz

STEP I : DOWNLOAD AND INSTALL GRAPHVIZ IN WINDOWS

Windows

Stable Windows install packages:

2.47.0 EXE installer for Windows 10 (64-bit):

stable_windows_10_cmake_Release_x64_graphviz-install-2.47.0-win64.exe

  • Install Graphviz

Open the downloaded Graphviz setup

Accept the License

Select Install option as below

Take a note of the INSTALL LOCATION

INSTALL Location is used while

  • setting up the Path in environment variable in System in Windows
  • Installing Pygraphviz in Anaconda Prompt

Select Graphviz and click on INSTALL

STEP II : SETUP ENVIRONMENT VARIABLES FOR GRAPHVIZ

Once the installation is complete

Navigate to “This PC” icon — Right click and select Properties — Advanced System Settings

And select “Environment Variables” — Path — Edit

Click on ADD button to ADD the INSTALL LOCATION of GRAPHVIZ

STEP III : INSTALL PYGRAPHVIZ IN ANACONDA PROMPT

Go to ANACONDA PROMPT and run the command to install PYGRAPHVIZ

python -m pip install — global-option=build_ext — global-option=”IC:\path to Graphviz include files” — global-option=”LC:\path to Graphviz library files” pygraphviz

#path to Graphviz include and library is INSTALL LOCATION set in Step I

Restart the Anaconda Navigator/Jupyter Lab or restart the system to let the configuration changes take place

STEP IV : IMPORT GRAPHVIZ AND PYGRAPHVIZ IN JUPYTER NOTEBOOK

Import graphviz and pygraphviz in Jupyter Notebook/Jupyter Lab using below code

--

--