IMHO you don’t need conda, this should do the job:
packages.txt
libgdal-dev
requirements.txt
pygdal==3.6.2.*
Be aware that the version of the binary package gdal
and pygdal
must match, see the documentation of the pygdal
package! Therefore the above version of pygdal
will change in the future or may be different on different linux OSes.
The pip install of pygdal seems to check the existing gdal version on the system. If you try to install pygdal on top of an gdal version that does not match, you will get:
GDALConfigError: Version mismatch 3.6.2 != 3.7.0
Someone has thought ahead
You could also check the versions in your application, for example:
import subprocess
from osgeo import gdal
pygdal_version = gdal.__version__
gdal_version = subprocess.check_output(['gdal-config','--version']).decode('utf-8').strip()
print(f'pygdal version: {pygdal_version}')
print(f'gdal version: {gdal_version}')
if pygdal_version == gdal_version:
print('GDAL versions match')
else:
print('GDAL versions do not match')