问题
I am playing around with using python iGraph for network visualization. I got his error message when I tried to plot a graph:
>>> layout = g.layout("kk")
>>> plot(g, layout = layout)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.5-x86_64/egg/igraph/drawing/__init__.py", line 446, in plot
File "build/bdist.macosx-10.5-x86_64/egg/igraph/drawing/__init__.py", line 117, in __init__
File "build/bdist.macosx-10.5-x86_64/egg/igraph/drawing/utils.py", line 396, in __getattr__
TypeError: plotting not available
I don't think I installed Cairo or PyCairo correctly.
I am not familiar using Fink or MacPorts, since I commonly use Homebrew.
Any help you be greatly appreciated.
回答1:
You need to manually compile the library. I used the solution here and just updated the version.
curl -L https://www.cairographics.org/releases/cairo-1.14.6.tar.xz -o cairo.tar.xz
tar -xf cairo.tar.xz && cd cairo-1.14.6
./configure --prefix=/usr/local --disable-dependency-tracking
make install
If while running configure, you get an error about pkg_config, you can install that with brew:
brew install pkg-config
回答2:
I had the same problem on my MacBook so I wanted to share my solution.
I tried to install pycairo
, py2cairo
. The installation seemed to be okay but then:
- I could not
import pycairo
- igraph's plot would not work.
The following solved the igraph plotting issue:
sudo pip install cairocffi
or just
pip install cairocffi
So instead of pycairo I used cairocffi and this did the trick.
来源:https://stackoverflow.com/questions/36225410/installing-cairo-and-pycairo-mac-osx