[FWTools] Python bindings to OGR

Frank Warmerdam warmerdam at pobox.com
Tue Sep 28 08:17:49 EST 2010


Cecília Cerdeira wrote:
> The script python already has the command
> 
> from osgeo import ogr
> 
> When I call it from the OSGeo4W shell, I get this message error:
> 
> E:\test_shp>pylas.py -i 32-2-502-114-23.las -o 32-output.shp > log.txt
> 
> Traceback (most recent call last):
> 
>   File "E:\test_shp\pylas.py", line 43, in <module>
> 
>     from osgeo import ogr
> 
>   File "C:\OSGeo4W\apps\gdal-dev\pymod\osgeo\__init__.py", line 21, in 
> <module>
> 
>     _gdal = swig_import_helper()
> 
>   File "C:\OSGeo4W\apps\gdal-dev\pymod\osgeo\__init__.py", line 17, in 
> swig_impo
> 
> rt_helper
> 
>     _mod = imp.load_module('_gdal', fp, pathname, description)
> 
> ImportError: DLL load failed: The operating system cannot run %1.
> 
> 
> What I am doing wrong?

Cecília,

Note that OSGeo4W does not install it's Python as the default system python.
And so you cannot run a .py file directly from the command shell.  Instead
you need to invoke Python explicitly.

eg.
Python pylas.py -i 32-2-502-114-23.las -o 32-output.shp > log.txt

I imagine you are getting another python installed on your system which
does not know about the extensions available to the OSGeo4W Python.

BTW, if anyone knows enough command shell magic for Win32 to make it
so that the OSGeo4W shell could use our own python automatically without
having any effect on non-OSGeo4W command shells, I'd be very interested.

It is a goal (at least for me) of OSGeo4W to coexist well with other
packages and to not replace/overwrite system versions of things like
Python, or DLLs.

PS. Why is this discussion happening on the FWTools list instead of the
OSGeo4W list?

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 FWTools mailing list