17

I am trying to get GeoDjango running on ubuntu and have hit a problem with GDAL.

I have downloaded and installed GDAL without problem.

I had to add the following line to my project settings:

GDAL_LIBRARY_PATH = '/usr/local/lib/libgdal.so.1.15.1'  

When I check in the shell all is good:

In [1]: from django.contrib.gis import gdal
In [2]: gdal.HAS_GDAL
Out[2]: True

However when I try and run ogrinfo as in the official tutorial I get the following error:

$ ogrinfo world/data/TM_WORLD_BORDERS-0.3.shp
ogrinfo: error while loading shared libraries: libgdal.so.1: cannot open shared object file: No such file or directory

GDAL files are located at:

/usr/local/lib/libgdal.a
/usr/local/lib/libgdal.la
/usr/local/lib/libgdal.so
/usr/local/lib/libgdal.so.1
/usr/local/lib/libgdal.so.1.15.1

libgdal.so and libgdal.so.1 both symlink to libgdal.so.15.1

Any help would be much appreciated.

Darwin Tech
  • 18,449
  • 38
  • 112
  • 187

4 Answers4

24

So, for the record, the answer was to add the library path /usr/local/lib/ to /etc/ld.so.conf, then run $ sudo ldconfig

Darwin Tech
  • 18,449
  • 38
  • 112
  • 187
6
sudo ldconfig

Often is all you need. Just check /etc/ld.so.conf before you start adding paths, /usr/local/lib may already be listed.

Brad Koch
  • 19,267
  • 19
  • 110
  • 137
2

According to django documentation 'The most common problem when installing GeoDjango is that the external shared libraries (e.g., for GEOS and GDAL) cannot be located.'

The usual path for gdal library installed via source is /usr/local/lib, Therefore if you run the bash command:

export LD_LIBRARY_PATH=/usr/local/lib

python should then be able to find

sirFunkenstine
  • 8,135
  • 6
  • 40
  • 57
0
$ sudo echo /usr/local/lib >> /etc/ld.so.conf
$ sudo ldconfig

https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#setting-system-library-path