How to install 'pygraphviz'?

Vamshikiran Morlawar
3 min readSep 3, 2022


I'll walk you through the steps that worked for me. The installation process depends on the operating system. I'll show the installation process for package/library pygraphviz on both operating systems, i.e. Windows and macOS.

Let's first look at the process for the macOS, and you can also check out the official documentation page of the pygraphviz to install it.

  1. Install Python on your system, preferably the latest version. You can download it from the official site
  2. Now let's get started with the installation of the pygraphviz. Before installing the package pygraphviz, we have to install the package called Graphviz.
    Install Graphviz using homebrew, open your terminal and run this command.
    brew install graphviz
  3. Run this command to get the location of the Graphviz we just installed, and copy the location of the file with the version (check the image for the reference)
    brew info graphviz
copy the file location (marked with red ink)

4 . Now, we have to store this path of Graphviz in the environment variable using the following command.

export GRAPHVIZ = “path you copied from the above step with version”

5. Run this command to install pygraphviz. If pip is not working for you, try pip3. You can also check this comment by Gino Mempin on StackOverflow

pip install pygraphviz --global-option=build_ext --global-option="-I$GRAPHVIZ/include" --global-option="-L$GRAPHVIZ/lib"

The above process should successfully install the pygraphviz for you in macOS. If this process fails, you can carefully go through the error message to know what's causing the problem and ask your best friend Google about it :)

For the windows operating system installing the pygraphviz package, I've used Chocolatey (a package manager for windows). Let's get started —

  1. Install Python on your system, preferably the latest version. You can download it from the official site
  2. Install Chocolatey if you don't have it already on your machine. You can visit to check the detailed steps.
  3. Now, install Graphviz using the command. Again you can check the official site to see this approach. . There are other ways to install the package, but the choco method worked for me.
    choco install graphviz
  4. Search for Graphviz as we need the location of this package to install pygraphviz. Most probably, you'll see this folder in your
    C:/Program Files or C:/Program Files (x86)
  5. In windows search, search for edit environment variables, or you can see this in the control panel. Go to the Graphviz folder you got from the previous step and open the folder to find the "bin folder" copy the location ~/your_path/Graphviz/bin.
    In the environment variable, click on the Path variable, click edit and add this location to it.
  6. Let's run the pygraphviz package installer, and you can check this command at the official documentation here, make sure you copy the command under the Chocolatey section.

If you are facing below error then follow the step [**] and then continue from step 2 in Windows OS section.
error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”:

[**] Follow this site to solve the above error ->

I hope this helps you install pygraphviz, and if it doesn't, don't worry. There are a bunch of sites with solutions. While solving these issues, I've referred to multiple sites, and reading the error message carefully helped a lot. Rather than the simple steps to install this package, I've faced a lot of trouble resolving this. Anyways, a big Thank you to all those community builders.

See you again on the next blog.