[GIS] “ImportError: No module named gdalsrsinfo” What’s the issue

gdalpython

in the python console I can call import gdal, and gdal is recognized as a module; however, most gdal programs, such as gdalinfo and gdalsrsinfo are not recognized. I checked the GDAL source files to see if there was a problem with the PYTHONPATH. They were not in the QGIS application resources, so I moved them manually… this still did not solve the problem.

if i enter gdalsrsinfo /Filepath/File.prj the console returns the error:

Traceback (most recent call last): File "", line 1, in
File
"/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py",
line 453, in _import
mod = _builtin_import(name, globals, locals, fromlist, level) ImportError: No module named gdalsrsinfo

However this is a function that should be included in GDAL by default. Why is it not recognized?

I am using the latest version from KyngChaos

Best Answer

GDAL isn't all in python. The core is written in C/C++. You can, of course, use the GDAL/OGR library parts from python

You can also use those library parts using other APIs, including compiled languages such as C or C++. That is what many (although not all) of the command line utilities do. There is a list of command line utilities at http://www.gdal.org/gdal_utilities.html - you can safely assume those that end with .py are python scripts and those that do not end with .py are compiled executables (.exe in windows terms, typically an ELF format program in Linux, or Mach-O on MacOS).

The python utilities are intended to be used from the command line (Terminal.app or similar), just like the executable format utilities. You may be able to make use of them by import in python, or by subprocess but there isn't anything GDAL specific in that invocation.

Related Question