Installing modules from source code

Here's an example of installing the Python module 'rtree' by compiling it from source.

The library libspatialindex 1.7 is required for package 'rtree'. Only version 1.6 is available for CentOS 6, unfortunately. You can try building the package in your home directory.

  1. wget http://download.osgeo.org/libspatialindex/spatialindex-src-1.8.5.tar.gz
  2. tar -xzf spatialindex-src-1.8.5.tar.gz
  3. cd spatialindex-src-1.8.5
  4. ./configure --prefix=~/
  5. make
  6. make install
  7. set the environmental variables:
    1. export SPATIALINDEX_LIBRARY=~/lib/libspatialindex.so
    2. export SPATIALINDEX_C_LIBRARY=~/lib/libspatialindex_c.so
  8. pip install git+https://github.com/Toblerity/rtree.git --user

Python has trouble finding the libspatialindex library and this is a known bug for which there was a specific fix implemented. You can find more on the discussion here: https://github.com/Toblerity/rtree/issues/56.

Unfortunately, the details of how to use the fix are poorly documented. The name of the environmental variable looks like it changed between the discussion, where it's referred to as SPATIALINDEX_LIBRARY_PATH; however, the sequence of commands above seem to work.