1

I wrote a simple example program using pydot:

import pydot

graph = pydot.Dot(graph_type='graph')
for i in range(3):
    edge = pydot.Edge("king", "lord%d" % i)
    graph.add_edge(edge)

graph.write_png('example_graph.png')

I installed pydot via apt-get: sudo apt-get install python-pydot

but when I try to run my code I get this error:

ImportError: No module named 'pydot'

What am I doing wrong?

Natjo
  • 2,005
  • 29
  • 75
  • Did you read the [readme](https://github.com/erocarrera/pydot) and follow its instructions? FWIW, you're probably better off using the more modern [pydotplus](https://pypi.python.org/pypi/pydotplus) which you can install with `pip`. Note that both of these packages need `pyparsing` and `GraphViz`. – PM 2Ring Apr 13 '16 at 12:14
  • 2
    Are you using python3 or python2? – frankenapps Apr 13 '16 at 12:19
  • I'm working with python3. And I added both packages. What I noticed: if I work only with the `graphviz` module (and different code than in my question) it compiles with python2, but python3 gives me the error it can't find the `graphviz` module... Is there a possibility to work with it using python3? – Natjo Apr 13 '16 at 15:43
  • 1
    `python-pydot` is the package for Python 2. You have to look for a `python3-pydot` package in your Linux distribution or make sure you install packages with `pip` for Python 3 and not the one for Python 2. – BlackJack Apr 14 '16 at 12:32

1 Answers1

0

Try installing the pydot module in pip/pip3,

$sudo pip3 install pydot

Biranchi
  • 16,120
  • 23
  • 124
  • 161