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 :: Anaconda.org), which in turn requires something called gdal (https://anaconda.org/conda-forge/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/script_runner.py", line 534, in _run_script
exec(code, module.__dict__)
File "/home/user/app/app.py", 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/foliumap.py", line 499, in add_raster
tile_layer, tile_client = get_local_tile_layer(
File "/home/user/.local/lib/python3.10/site-packages/leafmap/common.py", line 2818, in get_local_tile_layer
from osgeo import gdal
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:
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')
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.