I'm trying to install pygraphviz under Ubuntu 10.04 in order to use it within my Django projects.

I used synaptic and it was installed without any problem.

I also installed django-extensions with synaptic (django-extensions has a tool that uses pygraphviz and this is the one that I need)

Now when I try to use django-extensions with pygraphviz

$ python manage.py graph_models -a -g -o model.png

I'm getting an

Error: need pygraphviz python module ( apt-get install python-pygraphviz )

How can I fix this ?


Your script seems to be unable to find the pygraphviz module. To fix that, you should make sure that pygraphviz is in your Python's sys.path.

In case you find out the module is not installed, you have two alternative ways of installing it:

  • sudo apt-get install python-pygraphviz (as suggested by the error message),
  • sudo apt-get install graphviz libgraphviz-dev and
    sudo pip install pygraphviz --install-option='--include-path=/usr/include/graphviz' --install-option='--library-path=/usr/lib/graphviz'
    This is the method I strongly recommend, which uses pip, the Python package installer. Specifying the options is required because otherwise the pygraphviz installer seems unable to find the paths.
| improve this answer | |
  • sudo pip install pygraphviz fails because the graphviz package is a requirement. The only way to get this installed on Ubuntu in one go is with the first option: sudo apt-get install python-pygraphviz . – Luís de Sousa Jul 29 '15 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.