Search code examples
pythoncentosvirtualenvgdal

Installing gdal 1.11 with virtualenv


I have to install gdal 1.11 on my centos machine, and I got some problems with it.

I'm running on a virtualenv, using Python 2.7.5 instead of the Python 2.6 installed on my Centos

$ scl enable python27 bash
$ cd virtenv
$ source bin/activate
$ python -V
Python 2.7.5

Since yum didn't provide the right version of gdal, I've been building it from source, downloading the tar.gz

This is I've done.

$ cd gdal-1.11.0
$ ./configure --with-python
$ make
$ sudo make install

The last command shows me that it's building on the wrong version of Python, the 2.6 one.

What do I need to do to install it on the right version?

Thank you for your answer


Solution

  • This guide has excellent instructions for installing GDAL on CentOS and Ubuntu.

    http://scigeo.org/articles/howto-install-latest-geospatial-software-on-linux.html#gdal

    It recommends building GDAL without python support and then building the python wrappers after. In your case I guess this would be:

    $ cd gdal-1.11.0
    $ ./configure --without-python
    $ make install
    

    and then for the python wrappers. From the directory containing the source folder:

    $ cd gdal-1.11.0/swig
    $ make
    $ cd python
    $ python setup.py install
    

    Provided the virtualenv is active and your PYTHONPATH is set correctly when you call the python setup.py, it should build the correct version and install it to your virtualenv site-packages.