Reputation: 31
I've installed py2cairo using brew, but keep getting errors when trying to plot with igraph. I get the following error:
>>> import igraph as ig
>>> from igraph import *
>>> UG = ig.Graph()
>>> UG.add_vertex('a')
>>> UG.add_vertex('b')
>>> UG.add_vertex('c')
>>> UG.add_vertex('d')
>>> UG.add_edge('a','d')
>>> UG.add_edge('a','c')
>>> UG.add_edge('b','c')
>>> UG.add_edge('b','a')
>>> layout = UG.layout_kamada_kawai()
>>> plot(UG,layout = layout)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../anaconda/lib/python2.7/site-packages/igraph/drawing/__init__.py", line 427, in plot
result = Plot(target, bbox, background="white")
File ".../anaconda/lib/python2.7/site-packages/igraph/drawing/__init__.py", line 122, in __init__
self._surface_was_created = not isinstance(target, cairo.Surface)
File ".../anaconda/lib/python2.7/site-packages/igraph/drawing/utils.py", line 396, in __getattr__
raise TypeError("plotting not available")
TypeError: plotting not available
Upvotes: 3
Views: 5793
Reputation: 33197
I had the same problem. I tried to install pycairo, py2cairo but igraph's plot would not work.
The following solved the igraph plotting issue:
sudo pip install cairocffi
Instead of pycairo I used cairocffi and this solved my problem.
Upvotes: 0
Reputation: 11
try updating your PYTHONPATH variable, e.g. (insert your username in place of NNNN):
export PYTHONPATH=/Users/NNNN/anaconda/bin/python:$PYTHONPATH
Upvotes: 1
Reputation: 48101
brew
probably installs py2cairo
for its own Python, while you are running igraph under Anaconda Python. A module installed for one Python distribution on your machine will not appear magically under the other Python distribution, so you'll either have to get py2cairo
for Anaconda Python or compile the Python interface of igraph for Homebrew's Python.
Upvotes: 2