Installing PyGraphviz [tested on OSx Leopard]

PyGraphviz is a Python interface to the Graphviz graph layout and visualization package. With PyGraphviz you can create, edit, read, write, and draw graphs using Python to access the Graphviz graph data structure and layout algorithms.

[I was doing this in order to benefit from some of the django-command-extension functionalities]

1. Get graphviz here and install it (should be straightforward)

2. Download PyGraphViz. Make sure you download the source package. It’s possible to install it through easy_install but it would throw the following error:

bash-3.2$ easy_install pygraphviz
Searching for pygraphviz
Best match: pygraphviz 0.99.1
Running pygraphviz-0.99.1/ -q bdist_egg --dist-dir /var/folders/Cm/C.........
Trying pkg-config
/bin/sh: pkg-config: command not found
/bin/sh: pkg-config: command not found
Trying dotneato-config
Failed to find dotneato-config

Your graphviz installation could not be found.

Either the graphviz package is missing on incomplete
(binary packages graphviz-dev or graphviz-devel missing?).

If you think your installation is correct you will need to manually
change the include_path and library_path variables in to
point to the correct locations of your graphviz installation.

The current setting of library_path and include_path is:

error: None

3. Change by specifying where your graphViz installation is [more info here]:

# library_path=None
# include_path=None

4. Install:

bash-3.2$ python install
running install
running build
running build_py
creating build/lib.macosx-10.4-i386-2.5
creating build/lib.macosx-10.4-i386-2.5/pygraphviz
copying pygraphviz/ -> build/lib.macosx-10.4-i386-2.5/pygraphviz
copying pygraphviz/ -> build/lib.macosx-10.4-i386-2.5/pygraphviz
[...... etc. etc.......]

5. Enjoy!:

>>> import pygraphviz as pgv
>>> G=pgv.AGraph()
>>> G.add_node('a')
>>> G.add_edge('b','c')
>>> G
strict graph {
        b -- c;

#To load a dot file use

>>> G=pgv.AGraph("")



3 Responses to “Installing PyGraphviz [tested on OSx Leopard]”

thanks !

felix added these pithy words on Sep 19 12 at 10:59 am

Thanks. and if you’re using virtualenv, are those the same path you’re going to put in there ?

Stockman added these pithy words on Aug 06 13 at 8:17 am

Thank you very much!

I still get an error message after I run python install:

4 warnings generated.

gcc -bundle -undefined dynamic_lookup -L/Users/filippperesadilo/anaconda/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/pygraphviz/graphviz_wrap.o -L/usr/local/lib/graphviz -L/usr/local/lib/graphviz -lcgraph -lcdt -o build/lib.macosx-10.5-x86_64-2.7/pygraphviz/

ld: library not found for -lcgraph

clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: command ‘gcc’ failed with exit status 1

Any idea about what is going on?

Thanks in advance!

Peter added these pithy words on Dec 13 13 at 4:49 pm