[gdal-dev] Can't make Python binding work

Martin Hvidberg Martin at Hvidberg.net
Sun Dec 12 06:48:48 EST 2010


I'm trying to install and use GDAL in Python, and there seems to be 
something very fundamental that I'm missing.

To start with the problem... In a new python file I write:

try:

     fromosgeo importgdal

exceptImportError:

     importgdal


When run it replies:

Traceback (most recent call last):

_File "C:\Martin\Work_Eclipse\Hilfe\src\check_GDAL.py", line 8, in <module>_

         import gdal

ImportError: No module named gdal


To me that translates into, Python can't find the GDAL modules.

I'm running on a win-xp computer, I use python 2.6 as I recently 
upgraded to ArcGIS 10. Before that I used GDAL with Python 2.5 (and 
ArcGIS 9.x) that worked just fine.

I have no problems calling other Python add-ons, e.g. numpy.

I using GDAL from http://pypi.python.org/pypi/GDAL/

I downloaded http://download.osgeo.org/gdal/win32/1.6/gdalwin32exe160.zip

After unzipping to a dir of my choice I included the .../bin dir in my 
'path' and created a 'GDAL_DATA' environment variable pointing to .../data

It then looks like this:

C:\>echo %PATH%

C:\WINDOWS\system32;...<shortened>...;C:\APPS\PRO\gdalwin32-1.6\bin

C:\>echo %GDAL_DATA%

C:\APPS\PRO\gdalwin32-1.6\data

As I read the installation guide it should do it -- but it doesn't, as 
the code sample above indicates.

Though not mentioned in the installation guide, I also created an 
environmental variable PYTHONPATH, including the .../bin directory

C:\>echo %PYTHONPATH%

C:\APPS\PRO\gdalwin32-1.6\bin

Unfortunately this makes no deference to the program.

*Question 1*: Are there any problems in using GDAL 1.6 with Python 2.6 
on a win-xp?


Looking into ...\gdalwin32-1.6\bin\ in find no *.py files (nor *.pyc)

I would have expected some files with python extensions.

I also expected a file with the name 'osgeo.*' or 'gdal.*', since this 
is what the Pyhon import statement try to import. Alternatively a .zip 
file with such files inside. But non of that is in the 
...\gdalwin32-1.6\* to be found.

*Question 2: *Am I missing something here? How is this binding supposed 
to work? What file exactly is the import statement supposed to find, 
that will enable it to include osgeo functionality?


Best Regards

Martin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20101212/065574c1/attachment-0001.html


More information about the gdal-dev mailing list