Question

I have a Python script where I want to use the GDAL Python bindings.

Is it possible that I set the path to the bindings inside the script? Will that actually reflect the Python path?

For instance like this?

GDAL_LIBRARY_PATH = '/home/user123/lib/libgdal.so'
import gdal
print gdal.VersionInfo()
Was it helpful?

Solution

If it is an environment variable, I would set it up in os.environ before importing the module:

import os
os.environ['GDAL_LIBRARY_PATH'] = '/home/user123/lib/libgdal.so'
from osgeo import gdal
print(gdal.VersionInfo())

Mind you, this doesn't really do anything at all, since osgeo.gdal does not use this environment variable in any way. Django, however, uses a setting with this name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top