Create App using GDAL


I am working on creating an app located here,

which will read in some files with a .tif extension from my space. These are geospatial files which require the rioxarray package in python (Rioxarray ::, which in turn requires something called gdal (

I have a requirements file which includes the following:


According to this question Deploy in Streamlit cloud with GDAL, I also need a packages.txt file with libgdal-dev which I have also included, but even so when building my app it fails with the following:

File "/home/user/.local/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/", line 534, in _run_script
    exec(code, module.__dict__)
File "/home/user/app/", line 220, in <module>
    m.add_raster(selected_file, bands=[6], layer_name = 'dNBR', colormap='viridis')
File "/home/user/.local/lib/python3.10/site-packages/leafmap/", line 499, in add_raster
    tile_layer, tile_client = get_local_tile_layer(
File "/home/user/.local/lib/python3.10/site-packages/leafmap/", line 2818, in get_local_tile_layer
    from osgeo import gdal

Hi @sm-potter

Could you also try creating an environment.yml file to get gdal installed on Community Cloud as mentioned in the Docs (App dependencies - Streamlit Docs)

and for more details on creating the yml file, check out the following:

IMHO you don’t need conda, this should do the job:





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 :+1: :+1: :+1:

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')
    print('GDAL versions do not match')
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.