[GIS] How to add GDAL to existing Python installation

gdalpython

I would like to download and install GDAL for Python version 2.6 [MCS v.1500 32 bit(Intel)] on win32 that supports reading FileGDB's with Python. But I am not sure how to go about this.

I found one exe at this link but it was not built with the FileGDB included. I also tried the OSGeo4w Installer but it currently installs its own 2.7 version of Python rather than allowing the GDAL to be installed with the existing version of Python.

I must work with the 2.6 version installed on our systems. Can anyone be of assistance in locating a GDAL build that supports FileGDB's, can be installed with my existing Python version 2.6 and provide detailed instructions?

Best Answer

I was in the same situation as you it sounds like - I needed to install it to use the Python 2.6.5 install with ArcGIS. Here is how I did it.

ESRI FGDB API install

  1. Download and unzip the FGDB API from Esri at: http://resources.arcgis.com/content/geodatabases/10.0/file-gdb-api. Yes, you have to login to download it. Ver 1.1 at time of this writing, get the VS2010 version.

  2. Unzip the FGDB API to a directory, I did mine to C:\Program Files\ESRI FileGDB API. Add the path to the bin directory (mine is C:\Program Files\ESRI FileGDB API\bin) to your PATH environmental variable. FileGDBAPI.dll has to be in your PATH.

GDAL 1.9 install

  1. Download Win32 GDAL 1.9/Mapserver binary package from http://vbkto.dyndns.org/sdk/.

  2. Install the GDAL build by unzipping it to somewhere like C:\Program Files (x86)\GDAL.

  3. Setup and config of GDAL and plugins:

    • Path to /bin needs to be in PATH env. variable (C:\Program Files (x86)\GDAL\bin) Also, so does: C:\Program Files (x86)\GDAL\bin\gdal\apps and C:\Program Files (x86)\GDAL\bin\gdal\python

    • Copy ogr_FileGDB.dll from C:\Program Files (x86)\GDAL\bin\gdal\plugins-external to C:\Program Files\GDAL\bin\gdal\plugins

    • Create new env. variable named GDAL_DRIVER_PATH with value of C:\Program Files (x86)\GDAL\bin\gdal\plugins. This will make all of your plugin dlls available as drivers to GDAL.

  4. Test by running ogrinfo --formats

Python 2.6.5 support

Got this error when trying to import gdal:

C:\>cd "Program Files (x86)\GDAL\bin\gdal\python"

C:\Program Files (x86)\GDAL\bin\gdal\python>python
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import gdal
ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\bin\gdal\plugins\
gdal_GEOR.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\bin\gdal\plugins\
gdal_GEOR.dll
126: The specified module could not be found.

This is the driver for Oracle GeoRaster, which I don't need, so I moved gdal_GEOR.dll from \plugins to \plugins-optional.