WebFaction
Community site: login faq
0
2

I'm trying to install GDAL so that I can try out the raster functions of PostGIS2.0. I'm having difficulty installing GDAL such that python can import it (which I assume is necessary for PostGIS2.0).

I have downloaded GDAL 1.8.1 and used the following command to build it:

./configure --prefix=$HOME --with-python

This produces the following summary:

GDAL is now configured for i686-pc-linux-gnu

  Installation directory:    /home/user23
  C compiler:                gcc -g -O2
  C++ compiler:              g++ -g -O2

  LIBTOOL support:           yes

  LIBZ support:              external
  LIBLZMA support:           no
  GRASS support:             no
  CFITSIO support:           no
  PCRaster support:          internal
  NetCDF support:            no
  LIBPNG support:            external
  LIBTIFF support:           internal (BigTIFF=yes)
  LIBGEOTIFF support:        internal
  LIBJPEG support:           external
  8/12 bit JPEG TIFF:        no
  LIBGIF support:            internal
  OGDI support:              no
  HDF4 support:              no
  HDF5 support:              no
  Kakadu support:            no
  JasPer support:            no
  OpenJPEG support:          no
  ECW support:               no
  MrSID support:             no
  MrSID/MG4 Lidar support:   no
  MSG support:               no
  GRIB support:              yes
  EPSILON support:           no
  cURL support (wms/wcs/...):yes
  PostgreSQL support:        yes
  MySQL support:             no
  Ingres support:            no
  Xerces-C support:          no
  NAS support:               no
  Expat support:             yes
  Google libkml support:     no
  ODBC support:              yes
  PGeo support:              yes
  PCIDSK support:            internal
  OCI support:               no
  GEORASTER support:         no
  SDE support:               no
  Rasdaman support:          no
  DODS support:              no
  SQLite support:            yes
  SpatiaLite support:        no
  DWGdirect support          no
  INFORMIX DataBlade support:no
  GEOS support:              yes
  VFK support:               yes
  Poppler support:           no
  OpenCL support:            no

  SWIG Bindings:          python

  Statically link PROJ.4:    no
  enable OGR building:       yes
  enable pthread support:    yes
  hide internal symbols:     no

Then I run make and make install and the program appears to install ok. However when I check that python can import the gdal module I get the following error:

>>> [user23@web205 ~]$ python
Python 2.4.3 (#1, May  5 2011, 16:39:09) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gdal
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/user23/lib/python2.4/GDAL-1.8.1-py2.4-linux-i686.egg/gdal.py", line 2, in ?
    from osgeo.gdal import deprecation_warn
  File "/home/user23/lib/python2.4/GDAL-1.8.1-py2.4-linux-i686.egg/osgeo/__init__.py", line 24, in ?
    import _gdal
ImportError: /home/user23/lib/python2.4/GDAL-1.8.1-py2.4-linux-i686.egg/osgeo/_gdal.so: undefined symbol: GDALSetRasterUnitType

I have also tried to install gdal for python using easy_install (easy_install gdal) but this did not work either. I have also installed and built PostGIS2.0 without error, but it seems that it has not installed the raster functionality which is why I assumed that GDAL was the problem.

asked 07 Oct '11, 06:14

womble
15138
accept rate: 0%

edited 07 Oct '11, 06:15


SInce you have installed GDAL locally, you need to specify the path:

GDAL_LIBRARY_PATH = '/home/user23/lib/python2.7/libgdal.so'

Then test from your django project:

python2.7 manage.py shell
from django.contrib.gis import gdal
gdal.HAS_GDAL
True

If HAS_GDAL is True then it is installed correctly. Here is more on troubleshooting GDAL.

permanent link

answered 07 Oct '11, 08:29

timg ♦♦
1.3k4
accept rate: 30%

Thanks for the suggestion @timg .However I'm not using django, I just want to install GDAL with python for PostGIS/Postgresql. The line 'GDAL_LIBRARY_PATH = '/home/user23/lib/python2.7/libgdal.so'' did not work in my case.

(07 Oct '11, 12:25) womble

Please try setting LD_LIBRARY_PATH in your environment when invoking Python, eg:

LD_LIBRARY_PATH=$HOME/lib python

This will let the Python interpreter know where your custom libraries are.

permanent link

answered 07 Oct '11, 12:39

seanf
12.2k31836
accept rate: 37%

is this done during the install process of GDAL or set thereafter?

(01 Apr '12, 20:21) netcon
1

You'd actually want to have the LD_LIBRARY_PATH set correct for both - during build time (the install process) and also runtime thereafter.

When I install software, I set the following five environment variables right at the beginning before installation of anything:

export TMPDIR=$HOME/tmp
export PATH="$HOME/bin:$PATH"
export C_INCLUDE_PATH="$HOME/include:$C_INCLUDE_PATH"
export LIBRARY_PATH="$HOME/lib:$LIBRARY_PATH"
export LD_LIBRARY_PATH="$HOME/lib:$LD_LIBRARY_PATH"

Then, I make sure that the LD_LIBRARY_PATH is set correctly always, afterward:

export LD_LIBRARY_PATH="$HOME/lib:$LD_LIBRARY_PATH"

Usually by setting this value at the bottom of my $HOME/.bashrc file so it is set automatically on login.

(01 Apr '12, 20:29) ryans ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×108
×9
×2

question asked: 07 Oct '11, 06:14

question was seen: 7,327 times

last updated: 01 Apr '12, 20:29

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM