Compiling the python-igraph with Python 2.7 on CentOS 5

Step 1: Install Python 2.7

python-igraph requires Python 2.5 and above. Do look at Installing and Compiling Python 2.7.8 on CentOS 5

Step 2: Download and unpack python-igraph from python-igraph.

The current version is python-igraph 0.7

Step 3: Unpack and compile

# tar -zxvf python-igraph-0.7.0
# cd  python-igraph-0.7.0
# python setup.py install

If you encounter errors similar to /usr/lib64/libxml2.a: could not read symbols: Bad value

Step 4: Copy and update to /usr/local/

If you want to put all the packages in an easier to find directory. Copy

# mkdir -p /usr/local/python-igraph-0.7.0/bin
# mkdir -p /usr/local/python-igraph-0.7.0/lib
# cp $PYTHON-IGRAPH-HOME/build/scripts-2.7/igraph /usr/local/python-igraph-0.7.0/bin
# cp -rv $PYTHON-IGRAPH-HOME/build/scripts-2.7/lib.linux-x86_64-2.7/igraph /usr/local/python-igraph-0.7.0/lib
# cp -rv $PYTHON-IGRAPH-HOME/igraphcore/lib/libigraph.so* /usr/local/python-igraph-0.7.0/lib

Step 5: Test the python-igraph libraries.
Update .bashrc

export PATH=$PATH:/usr/local/python-igraph-0.7.0/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/python-igraph-0.7.0/lib

Test with python on the command line

$ python2.7
Python 2.7.8 (default, Jul 17 2014, 14:44:57)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph
>>>

 


*Easier Method*

You can use pip to install. For more information on how to install and use pip, see Installing and Compiling Python 2.7.8 on CentOS 5

 

References:

  1. Python, igraph in CentOS
  2. Installing python-igraph on linux

 

Installing and Compiling Python 2.7.8 on CentOS 5

Step 1: Download the Python 2.7.8 from Python Site

Step 2: Use GCC44 to compile. If you have not done it, do

# yum install gcc44 gcc44-c++ gcc44-gfortran

Step 3: Update your alias in your  .bashrc

alias gcc='gcc44'

Step 4: Configure python 2.7.8

# cd python-2.7.8
# ./configure --prefix=/usr/local/python-2.7.8
# make -j 8
# make install

Step 5: Update the PATH and LD_LIBRARY_PATH in your .bashrc

export PATH=$PATH:/usr/local/python-2.7.8/bin.........
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/python-2.7.8/lib

Step 6: Download get-pip.py
For more information see pip installation site

Create a directory inside python2.7 directory and put pip in that directory

# mkdir /usr/local/python-2.7.8/pip
# wget https://bootstrap.pypa.io/get-pip.py .

Step 7: Install pip with Administrator rights

# python2.7 get-pip.py

If setuptools (or distribute) is not already installed, get-pip.py will install setuptools for you.
To upgrade an existing setuptools (or distribute), run

# pip install -U setuptools
# pip install numpy