try this: from osgeo import gdal gdal.UseExceptions() gdal.Open('noexist.tif')
This is from: http://trac.osgeo.org/gdal/wiki/PythonGotchas On Sun, Aug 5, 2012 at 5:41 PM, Mike Toews <mwto...@gmail.com> wrote: > I would like to capture or show GDAL error messages in an interactive > Python shell. For instance, if trying to open an non-existing raster: > > from osgeo import gdal > ds = gdal.Open('noexist.tif') > > shows nothing in an interactive shell (PythonWin, IDLE), but shows > messages when used in a shell (cmd.exe or Bash): > > ERROR 4: `noexist.tif' does not exist in the file system, and is not > recognised as a supported dataset name. > > It appears this output is sent to stderr. How can this output also > appear in an interactive Python shell, such as PythonWin or IDLE? > > Thanks, > -Mike > _______________________________________________ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/gdal-dev >
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev