[gdal-dev] Can't make Python binding work
Jason Roberts
jason.roberts at duke.edu
Sun Dec 12 12:57:22 EST 2010
Martin,
http://vbkto.dyndns.org/sdk/ is a popular location for GDAL binaries and
bindings for Windows. For Python 2.6 on 32-bit Windows, I would recommend
downloading "MSVC2008 (Win32) -stable" from the first table on the page
(i.e. http://vbkto.dyndns.org/sdk/release-1500-gdal-1-7-mapserver-5-6.zip).
In that zip, you will find the GDAL binaries in the bin directory and the
Python bindings in the bin\gdal\python directory. To install the bindings,
you can probably copy the entire contents of \bin\gdal\python including the
osgeo subdir into your Python site-packages directory; if you are using the
Python 2.6 installed by ArcGIS 10, it will be something like
C:\Python26\ArcGIS10\Lib\site-packages.
To get the bindings working, you'll have to configure the GDAL environment
variables and PATH environment variable, so that the bindings can access the
GDAL binaries. If you used GDAL successfully in the past, you know what I'm
talking about.
Note that a bug in ArcGIS 9.3, 9.3.1, and 10 prevents the bindings from
working properly from "in-process" geoprocessing scripts. See the end of
http://trac.osgeo.org/gdal/wiki/PythonGotchas. I was told by an ESRI
developer that this was likely to be fixed in ArcGIS 10 SP1, but have not
received confirmation from him about it, nor have I tested it.
Good luck,
Jason
-----Original Message-----
From: gdal-dev-bounces at lists.osgeo.org
[mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of Christopher Barker
Sent: Sunday, December 12, 2010 12:20 PM
To: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] Can't make Python binding work
Martin Hvidberg wrote:
> To start with the problem... In a new python file I write:
> 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.
correct.
> I using GDAL from http://pypi.python.org/pypi/GDAL/
On that site, it says: "GDAL Python Bindings available at the Python
Cheeseshop. An executable installer is available for both Python 2.4 or
2.5 or as a Python egg."
but I don't see any Windows binaries for the python bindings, and that
note doesn't include 2.6 anyway, i suspect it hasn't been updated for a
while -- we really should have python 2.6 and 2.7 there, as well as GDAL
1.7.*
> I downloaded http://download.osgeo.org/gdal/win32/1.6/gdalwin32exe160.zip
That is the binaries for the gdal libs and command line utilities -- it
does not include th python bindings.
So you'll need to:
1) do: "easy install GDAL" -- which may find the binaries for you.
2) find a Windows installer for the binaries
3) download the source and do "python setup.py build", "python setup.py
install", but that will require that you have the right compiler set up.
> *Question 1*: Are there any problems in using GDAL 1.6 with Python 2.6
> on a win-xp?
I don't think there are any problems -- but it does look like there are
no easy-to-install binaries.
There are other binaries of GDAL around -- but I don't if any of them
have python bindings build in. FWTools and OSGeo4W do, but I don't know
if they are compatible with the ESRI-supplied python.
The state of binaries for Windows is not good -- but I'm not offering to
build them, so what can you do? If there is someone that does want to
supply easy-to-install Windows binaries for Python folks, but isn't sure
what they should do, I'd be glad to provide input on that, but I don't
work primarily on Windows, and compiling stuff there has always been a
pain for me.
> Looking into ...\gdalwin32-1.6\bin\ in find no *.py files (nor *.pyc)
>
> I would have expected some files with python extensions.
right -- that installer does not include the python bindings.
> What file exactly is the import statement supposed to find,
> that will enable it to include osgeo functionality?
You are looking for the right things -- properly installed, there will
be a "osgeo" package on your PYTHONPATH, probably in "site-packages"
Good luck, sorry I'm not more help.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev
More information about the gdal-dev
mailing list