I followed the installation instructions but when I do:

>>> import pygraphviz

I get an error like:

ImportError: libagraph.so.1: cannot open shared object file: No such file or directory

What is wrong?


Some Unix systems don’t include the Graphviz library in the default search path for the run-time linker. The path is often something like /usr/lib/graphviz or /sw/lib/graphviz etc. and it needs to be added to your search path. On *nix systems, the preferred way to do this is by setting the appropriate flags when building/installing pygraphviz. For example, if the Graphviz libraries are installed in /opt/lib/mygviz/ on your system:

pip install --global-option=build_ext \
            --global-option="-L/opt/lib/mygviz/" \
            --global-option="-R/opt/lib/mygviz/" \

In this example, the -L and -R flags tell the linker where to look for the required Graphviz libraries at build time and run time, respectively.


How do I compile pygraphviz under Windows?


See Windows for the latest on how to install Graphviz and pygraphviz on Windows.


Why don’t you distribute a pygraphviz Windows installer?


We would very much like to make binary wheels available for pygraphviz, but there are several complications. pygraphviz is a wrapper around Graphviz, which means that Graphviz must be installed, and Graphviz header files, libraries and command line executables must all be accessible for the wrapper. The recommended use of the Graphviz CLI poses challenges for wheel packaging.

See also

This GitHub issue for further discussion on wheels and packaging.