[gdal-dev] Python 1.6 bindings under Windows

Frank Warmerdam warmerdam at pobox.com
Mon Jul 27 22:40:50 EDT 2009


Markus Reinhold wrote:
> Dear all,
> I'm pretty sure it has been asked before, however I wasn't able to find 
> an answer to my question in the archive, so please bear with me...
> I'm using a number of oss geo tools under Windows using the OSGeo4W 
> binary distribution. I have installed the 1.6-version of GDAL and can 
> find it under c:\osgeo4w\apps\gdal-16. This directory also includes the 
> Python bindings that I want to use instead of my current ones. Now I'm 
> stuck on how to achieve this. The usual *from osgeo import gdal* always 
> supplies me with the current 1.5-version of the bindings, so I somehow 
> suspect that I have to tell Python to prefer the 1.6-pymod directory 
> over the one it usually uses - but how so?

Markus,

Normally this is accomplished as a side effect of running gdal16.bat to
switch to the GDAL 1.6 environment.  If you look at osgeo4w\bin\gdal16.bat
you will see it does:

   SET PYTHONPATH=%OSGEO4W_ROOT%\apps\gdal-16\pymod;%PYTHONPATH%

> A second question that is related to the first one: Is there any way to 
> check the version of the bindings that have been imported by a script - 
> anything analogous to "--version" on the command line?
> I'd appreciate any help.

The gdal.VersionInfo() function returns the version using GDALVersionInfo().
If no argument is passed "VERSION_NUM" is assumed, otherwise use the
following:

  * <ul>
  * <li> "VERSION_NUM": Returns GDAL_VERSION_NUM formatted as a string.  ie. "1170"
  * <li> "RELEASE_DATE": Returns GDAL_RELEASE_DATE formatted as a string.
  * ie. "20020416".
  * <li> "RELEASE_NAME": Returns the GDAL_RELEASE_NAME. ie. "1.1.7"
  * <li> "--version": Returns one line version message suitable for use in
  * response to --version requests.  ie. "GDAL 1.1.7, released 2002/04/16"
  * <li> "LICENCE": Returns the content of the LICENSE.TXT file from the 
GDAL_DATA directory.
  *      Before GDAL 1.7.0, the returned string was leaking memory but this is 
now resolved.
  *      So the result should not been freed by the caller.
  * </ul>

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list