Austin Williams
Austin Williams

Reputation: 183

Error installing python-igraph on Ubuntu (from command line)

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)

Upvotes: 2

Views: 2643

Answers (3)

nealmcb
nealmcb

Reputation: 13491

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

Upvotes: 3

Tam&#225;s
Tam&#225;s

Reputation: 48101

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.

Upvotes: 1

niteshd22
niteshd22

Reputation: 511

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.

Upvotes: 0

Related Questions