0

I am trying to create a plot with python igraph:

from igraph import *

vertices = ["one", "two", "three"]
edges = [(0,2),(2,1),(0,1)]

g = Graph(vertex_attrs={"label": vertices}, edges=edges, directed=True)

plot(g)

I have installed all of these:

sudo apt-get install libffi-dev
sudo pip install cffi
sudo pip install cairocffi

And I still get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/chovanec/anaconda3/lib/python3.5/site-packages/igraph/drawing/__init__.py", line 446, in plot
    result = Plot(target, bbox, background=kwds.get("background", "white"))
  File "/home/chovanec/anaconda3/lib/python3.5/site-packages/igraph/drawing/__init__.py", line 117, in __init__
    self._surface_was_created = not isinstance(target, cairo.Surface)
AttributeError: module 'cairo' has no attribute 'Surface'

I can't find what's causing it.

crysis405
  • 1,121
  • 2
  • 13
  • 26
  • 1
    You might have another module named `cairo` in your Python path that "shadows" the "real" `cairo` module. Type `import cairo; print cairo.__file__` to figure out where it is coming from. – Tamás Feb 06 '17 at 20:45
  • You're right it was pointing to the wrong this. I additionally had to install a newer version of igraph: https://github.com/igraph/python-igraph/issues/88 – crysis405 Feb 07 '17 at 10:59
  • Why on my os __file__ returns `no attribute` error – dia Jun 02 '18 at 18:37

0 Answers0