4

after installing py2cairo, cairo and igraph through homebrew, I ran across an issue where the cairo library is not getting imported.

I tried to run the following code in python3 shell

>>> from igraph import *
>>> g = Graph.Famous("petersen")
>>> plot(g)

And it gave me the error: TypeError: plotting not available

When I ran import cairo in the shell, it gave me:

>>> import cairo
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'cairo'

For debugging, please refer to the commands I used to install cairo, py2cairo and igraph

brew install cairo, py2cairo
brew install homebrew/science/igraph

And they are available in the following path: /usr/local/Cellar/

When I look at my python path, it is:

>>> import os
>>> os.path
<module 'posixpath' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/posixpath.py'>

None of py2cairo and cairo installations are available at the following path /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/, however igraph is present at the path

Can anyone help me solving this issue?

=========================================================================== UPDATE:

I tried solving the issue by (refer: Can't load Python modules installed via pip from site-packages directory) running the following commands from the python shell and this time I can import cairo inside python shell.

>>> import sys
>>> sys.path.append("/usr/local/Cellar")
>>> import cairo

However, it fails on the plot(g) line with the following error.

>>> plot(g)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File      "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-    packages/igraph/drawing/__init__.py", line 446, in plot
result = Plot(target, bbox, background=kwds.get("background", "white"))
  File     "/Library/Frameworks/Python.framework/Versions/3.5/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'

ANY help would be appreciated

valafar
  • 190
  • 1
  • 2
  • 10

0 Answers0