Installing Cairo and PyCairo Mac OsX

狂风中的少年 提交于 2021-01-28 01:52:06

问题


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:

  1. I could not import pycairo
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!