Pip install pygraphviz fails: Failed building wheel for pygraphviz

Try this :

sudo apt-get install python-dev graphviz libgraphviz-dev pkg-config

or the following might be needed if you're using Python 3:

sudo apt-get install python3-dev graphviz libgraphviz-dev pkg-config

then

sudo pip install pygraphviz

The comment by Andrew brought me on the right path. Thank you for that.

It turns out that a detailed solution for installing pygraphviz on macOS is already available on stackoverflow, see this solution by teut.


Basically you need to download graphviz first using brew:

brew install graphviz

pip install graphviz

pip install pygraphviz 

You can also try using pip3 in place of pip just in case there is Python's version issue. Hope it helps.