[GIS] Importing osgeo module in Ubuntu 10.04

gdalosgeopython

I have problem with importing "osgeo" module in Ubuntu 10.04; I have installed GDAL 1.7 from source ( 1)./configure 2)make) however, still in Python I can't import osgeo module. I appreciate any hints.

Basically, I am trying to make the converter script of jvectormap script into work and osgeo module is a prerequisite module.

update 1 ./configure –with-python gives me the following

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

  Installation directory:    /usr/local
  C compiler:                gcc -g -O2
  C++ compiler:              g++ -g -O2

  LIBTOOL support:           yes

  LIBZ support:              external
  GRASS support:             no
  CFITSIO support:           no
  PCRaster support:          internal
  NetCDF support:            yes
  LIBPNG support:            external
  LIBTIFF support:           external (BigTIFF=no)
  LIBGEOTIFF support:        internal
  LIBJPEG support:           external
  8/12 bit JPEG TIFF:        no
  LIBGIF support:            external
  OGDI support:              no
  HDF4 support:              yes
  HDF5 support:              yes
  Kakadu support:            no
  JasPer support:            yes (GeoJP2=yes)
  ECW support:               no
  MrSID 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:          yes
  NAS support:               no
  Expat support:             yes
  ODBC support:              yes
  PGeo support:              yes
  PCIDSK support:            internal
  OCI support:               no
  GEORASTER support:         no
  SDE support:               no
  DODS support:              no
  SQLite support:            yes
  SpatiaLite support:        no
  DWGdirect support          no
  INFORMIX DataBlade support:no
  GEOS support:              yes
  VFK support:               yes


  SWIG Bindings:          python 

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

update 2

after importing gdal, I am getting the following complains:

>>> import gdal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/GDAL-1.7.1-py2.6-linux-i686.egg/gdal.py", line 2, in <module>
    from osgeo.gdal import deprecation_warn
  File "/usr/local/lib/python2.6/dist-packages/GDAL-1.7.1-py2.6-linux-i686.egg/osgeo/__init__.py", line 21, in <module>
    _gdal = swig_import_helper()
  File "/usr/local/lib/python2.6/dist-packages/GDAL-1.7.1-py2.6-linux-i686.egg/osgeo/__init__.py", line 17, in swig_import_helper
    _mod = imp.load_module('_gdal', fp, pathname, description)
ImportError: libgdal.so.1: cannot open shared object file: No such file or directory

I tried to see where the package is install :

$ /sbin/ldconfig -p | grep gdal
    libgdal1.7.0.so.1 (libc6) => /usr/lib/libgdal1.7.0.so.1
    libgdal1.6.0.so.1 (libc6) => /usr/lib/libgdal1.6.0.so.1
    libgdal1.6.0.so (libc6) => /usr/lib/libgdal1.6.0.so

Best Answer

If you install GDAL from source and you want the GDAL Python bindings, you need to configure it with Python:

./configure --with-python

In your output you should find:

...
Poppler support:           no
Podofo support:            no
OpenCL support:            no
Armadillo support:         no
FreeXL support:            yes

SWIG Bindings:             python

Statically link PROJ.4:    no
enable OGR building:       yes
...
Related Question