Ask Your Question
1

can't use networkx.read_dot()

asked 2012-01-19 11:36:09 -0500

When trying the following

import networkx
networkx.read_dot("foo.dot")

I get

ImportError                               Traceback (most recent call last)

/home/bla/tmp/<ipython console> in <module>()

/local/usr/share/sage/local/lib/python/networkx/drawing/nx_agraph.pyc in read_dot(path)
    197     except ImportError:
    198         raise ImportError, \
--> 199           "read_dot() requires pygraphviz: http://networkx.lanl.gov/pygraphviz"
    200     A=pygraphviz.AGraph(file=path)
    201     return from_agraph(A)

ImportError: read_dot() requires pygraphviz: http://networkx.lanl.gov/pygraphviz

It seems that I'm missing something really simple here. After a fair time browsing the documentation, however, I couldn't find what :(

Thanks in advance.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2012-01-19 12:35:35 -0500

Shashank gravatar image

updated 2012-01-20 18:04:50 -0500

Have you installed the optional package

http://www.sagemath.org/packages/opti...

If not this command won't work.

Run the command sage -i dot2tex-2.8.7-2 to install it.

You can find a list of optional packages at

http://www.sagemath.org/packages/opti...

Edit:

Sorry I posted that without trying it out just by looking at the manual, but I managed to solve the problem. Here are the steps I did to make it run.

1)

install optional package dot2tex

2)

install optional package graphviz from the same page (http://www.sagemath.org/packages/opti...)

3)

At the terminal type

$sage -sh

$easy_install pygraphviz

That way I was able to run a simple pygraphviz example.

edit flag offensive delete link more

Comments

I did not have dot2tex installed. Now I have but the situation is unchanged: same error message. Thanks for the ready answer anyway!

rc gravatar imagerc ( 2012-01-20 01:53:44 -0500 )edit

I have updated the answer. Hope this time it works

Shashank gravatar imageShashank ( 2012-01-20 18:04:26 -0500 )edit

It did! Thanks a lot! Where should I have looked in order figure this?

rc gravatar imagerc ( 2012-01-21 02:08:47 -0500 )edit

Unfortunately this is not mentioned in the sage manual. I just realized that pygraphviz is not install along with dot2tex as it should be according to the manual. easy_install is the standard procedure for installing modules are not listed under optional sage packages. So I tried it and it worked.

Shashank gravatar imageShashank ( 2012-01-21 09:10:41 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-01-19 11:36:09 -0500

Seen: 694 times

Last updated: Jan 20 '12