2

I'm trying to install python-igraph from command line. I created a new Ubuntu instance on an AWS server, so I have to do everything from command line. Here is what I have done from a fresh install of Ubuntu:

$sudo apt-get update
$sudo apt-get install build-essential
$sudo apt-get install python-dev
$sudo apt-get update
$sudo apt-get install python-pip
$sudo apt-get update
$sudo pip install python-igraph

I get the following error:

Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/python-igraph/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-XxxMbQ-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/python-igraph
Traceback (most recent call last):
 File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
 File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 235, in main
return command.main(cmd_args)
 File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 161, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 32: ordinal not in range(128)
1

3 Answers 3

3

I got it working on Ubuntu 14.04, inside a virtualenv. It wouldn't be simple to just install the Ubuntu package for python-igraph, since my virtualenv does not include site-packages, IIRC.

Thanks to the helpful and encouraging answer from @Tamás I dug in a bit more when I got the odd UnicodeDecodeError. It seems the real error was

/usr/bin/ld: cannot find -lxml2

but it happened after about 13000 lines of build output in which lots of use seemed to have been made of -lxml2 successfully. Odd.

But based on some advice at

http://igraph.wikidot.com/installing-python-igraph-on-linux#toc0

I installed some libraries:

sudo aptitude install build-essential libxml2-dev libglpk-dev libgmp3-dev libblas-dev liblapack-dev libarpack2-dev python-dev

I was told:

The following NEW packages will be installed: libarpack2-dev libbtf1.2.0{a} libcsparse3.1.2{a} libcxsparse3.1.2{a} libglpk-dev libgmp-dev{a} libgmp3-dev libgmpxx4ldbl{a} libklu1.2.1{a} libldl2.1.0{a} libspqr1.3.1{a} libsuitesparse-dev{a} libxml2-dev

After that, the pip install python-igraph succeeded. I kept the whole output in both cases in case someone can use that to fix the packaging issues and help make this more robust.

Bonus tip: Next I couldn't figure out how to get the python cairo bindings, since the igraph documentation didn't talk about a Linux installation of the cairo bindings, and on my own I was getting this error which led me on a frustrating and unsuccessful chase of its own:

Could not find any downloads that satisfy the requirement pycairo
Some externally hosted files were ignored (use --allow-external pycairo to allow).

The solution was to use the more recent set of bindings:

pip install cairocffi
Sign up to request clarification or add additional context in comments.

1 Comment

oh, thank you so much @Nealmcb I think it was not an easy debug!
1

This seems to be at least partly coming from pip - something goes wrong during pip install python-igraph, an exception is raised, pip catches the exception and tries to save the output into its log file. Unfortunately, a non-ASCII character in the output prevents pip from writing into the log file and that's the final exception that you see (not the actual cause of the error). In most of the cases, the non-ASCII characters come from the name of your home directory or your working directory, so first make sure that there aren't any non-ASCII characters in either of them. If that doesn't work, you have to set the default encoding of Python to utf-8 by creating a file named sitecustomize.py somewhere in your Python path and adding this code:

import sys
sys.setdefaultencoding('utf-8')

This will tell Python to encode IO operations with the UTF-8 encoding instead of ASCII - hopefully this would enable pip to complete the logging phase, and then you can take a look at the actual output. Don't forget to remove sitecustomize.py when you are done with debugging.

3 Comments

Hey @Tamás, what's the difference between using pip and apt-get to install igraph? Check my comment on the answer above, I was able to get apt-get to work but was unsuccessful with pip. Let me know and thanks!
apt-get install just downloads and copies a pre-compiled igraph library to the appropriate place on your system. pip install downloads the source code and tries to compile it from scratch, although I tried to make it as automatic as possible. If you have some time, please post the output of pip install python-igraph somewhere so I can take a look at it and figure out what goes wrong on your machine.
Thanks @Tamás See my answer for some extra details.
0

To install pyhton-igraph on Ubuntu try following steps:

  1. sudo add-apt-repository ppa:igraph/ppa
  2. sudo apt-get update
  3. sudo apt-get install python-igraph

p.s There is no package python-igraph available for 12.04 version.

1 Comment

I've been fighting the igraph install on Ubuntu 12.04 all day using pip. Just tried apt-get install python-igraph and it installed no problem. Not exactly sure why pip is failing. Someone else can chime in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.