문제

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()
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top