OGR Module – No OGR Module Despite GDAL Installed

gdalogrpython

I am trying to use the mapping component of the wonderful PySAL package, but for some reason I do not have the ogr module. I was under the impression that it came packaged with gdal. Am I missing something?

import gdal
import ogr

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-29-ef9eb3418665> in <module>()
----> 1 import gdal
      2 import ogr

ImportError: No module named gdal

UPDATE: I am afraid I was in a bit of a hurry to catch a plane, so I failed to include some critical information. I already installed python-gdal using the apt-get method described here, because I wanted to leave little to chance. Is it possible that the package manager did not install it correctly?

choct155@choct155-Q550LF:~$ sudo apt-get install python-gdal
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-gdal is already the newest version.
The following packages were automatically installed and are no longer required:
  firefox-globalmenu libfftw3-3 libgeos-3.3.3 libogdi3.2 libxerces-c28
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 33 not upgraded.

I am afraid I am not finding osgeo either…

from osgeo import gdal

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-28-a04b80bf4e65> in <module>()
----> 1 from osgeo import gdal

ImportError: No module named osgeo

Additionally, I should add that I am using Ubuntu 13.04.

Best Answer

Use these commands:

sudo apt-get install python-gdal
sudo apt-get install gdal-bin