27

I installed python-igraph 0.5.4 and igraph 0.5.4 (also tested 0.6) from source on a RHEL machine. All is fine except when I try to plot I get.

"TypeError: plotting not available"

There were no errors or warnings in the configure or install stages.

What do I need to install on linux to get plotting to work? I don't have root so will need to install it from source.

Raphael
  • 716
  • 1
  • 7
  • 19

4 Answers4

15

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.

seralouk
  • 22,948
  • 5
  • 82
  • 101
13

igraph uses the Cairo library for plotting, so you will need Cairo and its Python interface. Chances are that Cairo is already installed on your machine (look for files named libcairo* in /usr/lib and /usr/lib64), so you just need the Python interface of Cairo.

There is one catch, though. In order to compile the Python interface of Cairo, you will need Cairo's header files, which might or might not be present on your system. If they are not installed, you can download Cairo's source and get the include files from there.

Tamás
  • 44,085
  • 11
  • 94
  • 119
  • It seems I have cairo 1.2.4 installed and a modern pycairo needs a much newer version. Does igraph 0.6 require a modern pycairo or can I use an old version of that too? – Raphael Aug 22 '12 at 18:23
  • I should say I attempted to install a newer cairo in my home directory but it also needs pixman and I couldn't resolve the dependencies/work out how to tell it where the libraries were. – Raphael Aug 22 '12 at 18:24
  • You can use an older PyCairo, it should work. Just make sure it matches the version of Cairo on your machine. – Tamás Aug 22 '12 at 21:04
  • Thanks I got it to work in the end. The final trick was to realise that PYTHONPATH may need to have more than one directory in it depending on where the modules happen to be installed. In particular, I needed both .../lib/python2.6/site-packages and .../lib/python – Raphael Aug 24 '12 at 16:45
  • "brew install cairo" was the missing piece for me on Mac OS X. A very very painful trip down a long and narrow and thorny rabbit hole of installing and uninstalling and setting and unsetting and exporting and unexporting and activating and unactivating and god knows what scrambled state my Python world is in after all that. – Reb.Cabin Nov 26 '17 at 13:44
2

I had the same problem (Windows). You have to install Cairo.

Unfortunately, there is no official assembly for windows. But there are unofficial ones.

Notes:

  • cpXX means version of python (check: python -V)
  • execute in the folder with the file: pip install *.whl (versio of pip must be higher than 19)

See the official installation tutorial for more details (chpter igraph on Windows).

2

As pointed out already by several respondents, pycairo is likely required in this case. Installation of pycairo using Conda fixed the issue on my machine within less than a minute:

conda install -c conda-forge pycairo

I assume that the same result can be achieved using PIP:

pip install pycairo
Unis
  • 423
  • 1
  • 3
  • 12