pygraph – Parerga und Paralipomena http://www.michelepasin.org/blog At the core of all well-founded belief lies belief that is unfounded - Wittgenstein Wed, 14 Oct 2009 14:43:42 +0000 en-US hourly 1 https://wordpress.org/?v=5.2.11 13825966 Installing PyGraphviz [tested on OSx Leopard] http://www.michelepasin.org/blog/2009/10/14/installing-pygraphviz-tested-on-osx-leopard/ http://www.michelepasin.org/blog/2009/10/14/installing-pygraphviz-tested-on-osx-leopard/#comments Wed, 14 Oct 2009 14:43:42 +0000 http://magicrebirth.wordpress.com/?p=370 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
Reading http://pypi.python.org/simple/pygraphviz/
Reading http://networkx.lanl.gov/pygraphviz
Reading http://networkx.lanl.gov/wiki/download
Reading http://sourceforge.net/project/showfiles.php?group_id=122233&package_id=161979
Reading http://networkx.lanl.gov/download
Best match: pygraphviz 0.99.1
Downloading http://pypi.python.org/packages/source/p/pygraphviz/pygraphviz-0........
Processing pygraphviz-0.99.1.zip
Running pygraphviz-0.99.1/setup.py -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 setup.py to
point to the correct locations of your graphviz installation.

The current setting of library_path and include_path is:
library_path=None
include_path=None

error: None

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

# library_path=None
library_path='/usr/local/lib/graphviz'
# include_path=None
include_path='/usr/local/include/graphviz'

4. Install:

bash-3.2$ python setup.py install
library_path=/usr/local/lib/graphviz
include_path=/usr/local/include/graphviz
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/__init__.py -> build/lib.macosx-10.4-i386-2.5/pygraphviz
copying pygraphviz/agraph.py -> 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 {
        a;
        b -- c;
}

#To load a dot file use

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

 

]]>
http://www.michelepasin.org/blog/2009/10/14/installing-pygraphviz-tested-on-osx-leopard/feed/ 3 370