pygraphviz errors

192 views
Skip to first unread message

Aref

unread,
Oct 19, 2009, 7:06:46 PM10/19/09
to pygraphviz-discuss
Hello,

I am fairly new to python and to this group so please excuse me if the
topic has been covered or seems idiotic.
I have Cygwin installed on my windows machine running XP. I have
downloaded and installed graphviz2.24 and pygraphviz-0.99.1 When I run
a pygraphviz script I get an error saying:

Segmentation fault (core dumped).

This is the script I am running:

import pygraphviz as pgv
import os, tempfile
G=pgv.AGraph(name='test graph')
nodelist=['a','b','c']
G.add_nodes_from(nodelist)
G.node_attr['shape']='circle'
G.add_edge('a','b')
G.add_edge('b','c')
G.add_edge('a','c')
print G
G.layout()
G.draw('test1.png')
os.close
os.unlink

G.layout() seems to be the problem. If I remove the line I do not get
an error but nothing else happens.
Any insight is greatly appreciated.
One more question--I have another python installation part of python
(x,y) can I install and run pygraphviz from there instead from cygwin?

Many thanks.

Aric Hagberg

unread,
Oct 19, 2009, 7:30:15 PM10/19/09
to pygraphvi...@googlegroups.com
On Mon, Oct 19, 2009 at 5:06 PM, Aref <arefn...@gmail.com> wrote:
> I am fairly new to python and to this group so please excuse me if the
> topic has been covered or seems idiotic.
> I have Cygwin installed on my windows machine running XP. I have
> downloaded and installed graphviz2.24 and pygraphviz-0.99.1 When I run
> a pygraphviz script I get an error saying:
>
> Segmentation fault (core dumped).
>
> This is the script I am running:
>
> import pygraphviz as pgv
> import os, tempfile
> G=pgv.AGraph(name='test graph')
> nodelist=['a','b','c']
> G.add_nodes_from(nodelist)
> G.node_attr['shape']='circle'
> G.add_edge('a','b')
> G.add_edge('b','c')
> G.add_edge('a','c')
> print G
> G.layout()
> G.draw('test1.png')
> os.close
> os.unlink
>
> G.layout() seems to be the problem. If I remove the line I do not get
> an error but nothing else happens.

In G.layout() the Graphviz command line tools are run using
the Python subprocess module.

So it could be a symptom of a problem with your Graphviz installation.
Can you run "dot" or other Graphviz tools? You can try with
a simple dot file (adjust for Windows syntax):

$ echo "graph {}" |dot
graph {
node [label="\N"];
graph [bb="0,0,0,0"];
}

> One more question--I have another python installation part of python
> (x,y) can I install and run pygraphviz from there instead from cygwin?

Should be able to. You need a working version of Graphviz and
a C compiler (as far as I know the same compiler version should
be used to build both Graphviz and Python).

Aric

Aref

unread,
Oct 19, 2009, 7:47:43 PM10/19/09
to pygraphviz-discuss
Thanks Aric, I tried the command line you suggested and got exactly
what you showed

here it is:

$ echo "graph{}" | dot
graph {
node [label="\N"];
graph [bb="0,0,0,0"];
}

I have run graphviz executables and things seem to work fine. I have
not tried from command line though. I will try.
Thanks again

On Oct 19, 5:30 pm, Aric Hagberg <ahagb...@gmail.com> wrote:

Aref

unread,
Oct 19, 2009, 8:40:45 PM10/19/09
to pygraphviz-discuss
I wrote a little test file and saved it as test1.dot from the command
line I typed dot test1.dot and here is what I got


$ dot test1.dot
graph test123 {
node [label="\N"];
graph [bb="0,0,167,180"];
{
graph [bb=""];
x [pos="99,90", width="0.75", height="0.5"];
y [pos="140,18", width="0.75", height="0.5"];
}
a [pos="99,162", width="0.75", height="0.5"];
b [pos="27,90", width="0.75", height="0.5"];
c [pos="41,18", width="0.75", height="0.5"];
a -- b [pos="83.731,146.73 71.512,134.51 54.46,117.46
42.247,105.25"];
b -- c [pos="30.533,71.831 32.671,60.833 35.387,46.865
37.517,35.913"];
a -- x [pos="99,143.83 99,133 99,119.29 99,108.41"];
a -- y [pos="112.85,146.2 120.87,136.03 130.3,122.11 135,108
142.97,84.098 142.89,54.663 141.74,36.108"];
x -- c [w="10.0", pos="86.128,74.021 76.516,62.089
63.439,45.855 53.836,33.934"];
x -- y [w="5.0", len=3, pos="108.72,72.937 115.25,61.46
123.83,46.392 130.35,34.941"];
}

test1.dot file has the following:

graph test123 {
a--b--c;
a--{x y};
x--c [w=10.0];
x--y [w=5.0,len=3];
}

It seems that graphviz is working OK.

Aric Hagberg

unread,
Oct 19, 2009, 10:46:57 PM10/19/09
to pygraphvi...@googlegroups.com
On Mon, Oct 19, 2009 at 6:40 PM, Aref <arefn...@gmail.com> wrote:
>
> I wrote a little test file and saved it as test1.dot from the command
> line I typed dot test1.dot and here is what I got
>
>
> It seems that graphviz is working OK.

OK - good. This might be a little tricky to debug but
here are some things to try that might give a clue.

>>> import pygraphivz as pgv
>>> pygraphviz.test() # probably will segfault
>>> A=pgv.AGraph()
>>> A.write() # write emtpy graph to stdout
>>> A.to_string() # write string version of empty graph
>>> A._run_prog() # run the graphviz 'nop' program using subprocess module
>>> A._run_prog('neato')# run 'neato' on graph

Aric

Aref

unread,
Oct 20, 2009, 8:01:00 PM10/20/09
to pygraphviz-discuss

> >>> import pygraphivz as pgv
> >>> pygraphviz.test() # probably will segfault
> >>> A=pgv.AGraph()
> >>> A.write() # write emtpy graph to stdout
> >>> A.to_string() # write string version of empty graph
> >>> A._run_prog() # run the graphviz 'nop' program using subprocess module
> >>> A._run_prog('neato')# run 'neato' on graph

I tried what you suggested and the only thing that worked or at least
seemed to was the import and A=pgvAGraph()
All the rest failed but not all generated seg fault message. Here is
what I got. It seems that any thing having to do with outputing fails.

Aref@home2 /usr/lib/python2.5
$ python
Python 2.5.2 (r252:60911, Dec 2 2008, 09:26:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygraphviz as pgv
>>> pygraphviz.test()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'pygraphviz' is not defined
>>> pgv.test()

Aref@home2 /usr/lib/python2.5
$ python
Python 2.5.2 (r252:60911, Dec 2 2008, 09:26:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygraphviz as pgv
>>> A = pgv.AGraph()
>>> A.write()
Segmentation fault (core dumped)

Aref@home2 /usr/lib/python2.5
$ python
Python 2.5.2 (r252:60911, Dec 2 2008, 09:26:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygraphviz as pgv
>>> A=pgv.AGraph()
>>> A.to_string()

Aref@home2 /usr/lib/python2.5
$ python
Python 2.5.2 (r252:60911, Dec 2 2008, 09:26:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygraphviz as pgv
>>> A=pgv.AGraph()
>>> A._run_prog()
Segmentation fault (core dumped)

Aref@home2 /usr/lib/python2.5
$ python
Python 2.5.2 (r252:60911, Dec 2 2008, 09:26:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygraphviz as pgv
>>> A=pgv.AGraph()
>>> A._run_prog('neato')
Segmentation fault (core dumped)

Again thank you so much for taking the time to help with this problem--
I am truly at a loss due to my lack of experience.

Aref

unread,
Oct 20, 2009, 8:37:33 PM10/20/09
to pygraphviz-discuss

I think I might have an idea of what might be wrong. When I installed
pygraphviz I already had graphviz--windows version--installed and it
was installed using a windows installers (msi). I was looking in the
pygraphviz setup.py file and it is looking for a file called dotneato-
config which I can't find anywhere in graphviz folders. I tried to
search for graphviz-dev which supposedly contains this file but I
cannot find such a file. Although during the installation of
pygraphviz no errors were reported about not finding the dotneato-
config file !!!

Aric Hagberg

unread,
Oct 20, 2009, 8:46:32 PM10/20/09
to pygraphvi...@googlegroups.com

It might be you have some conflicting installations.

I'm not sure how cygwin works but in more recent Linux distributions
graphviz packages use pkg-config instead of dotneato-config (and the
setup.py file handles that). Also the Linux graphviz-dev package has
been renamed libgraphviz-dev.

Aric

Reply all
Reply to author
Forward
0 new messages