i’m just trying to load some shape files in to streamlit and want to use geopandas to read the files in from github where i’ve added them…
i’ve got the following libraries in my requirements.txt file
altair
pandas
streamlit
shapely
fiona
pyproj
gdal
geopandas
and am getting the following error
File "/home/appuser/.local/lib/python3.7/site-packages/streamlit/script_runner.py", line 332, in _run_script
exec(code, module.__dict__)
File "/app/streamlit-example/streamlit_app.py", line 41, in <module>
city = gpd.read_file("https://github.com/alibama/streamlit-example/blob/master/planning_area_09_03_2020.shp")
File "/home/appuser/.local/lib/python3.7/site-packages/geopandas/io/file.py", line 96, in _read_file
with reader(path_or_bytes, **kwargs) as features:
File "/home/appuser/.local/lib/python3.7/site-packages/fiona/collection.py", line 556, in __init__
encoding='utf-8', **kwds)
File "/home/appuser/.local/lib/python3.7/site-packages/fiona/collection.py", line 162, in __init__
self.session.start(self, **kwargs)
File "fiona/ogrext.pyx", line 540, in fiona.ogrext.Session.start
File "fiona/_shim.pyx", line 81, in fiona._shim.gdal_open_vector
Hi @randyzwitch - i think the issue is with the fiona library - i’m trying to open files and i think fiona wants to do some file conversion juju on the back end? so maybe it’s a file system issue?
i dunno… shape files are common (but they are also proprietary BS, so there’s that…). i’m going to look and see if i can get the data in geojson and if that works i’ll post that approach on here for the next soul
File "/home/appuser/.local/lib/python3.7/site-packages/streamlit/script_runner.py", line 332, in _run_script
exec(code, module.__dict__)File "/app/streamlit-example/streamlit_app.py", line 43, in <module>
test = gpd.read_file("https://github.com/alibama/streamlit-example/raw/master/planning_area_09_03_2020.shp")File "/home/appuser/.local/lib/python3.7/site-packages/geopandas/io/file.py", line 96, in _read_file
with reader(path_or_bytes, **kwargs) as features:File "/home/appuser/.local/lib/python3.7/site-packages/fiona/collection.py", line 556, in __init__
encoding='utf-8', **kwds)File "/home/appuser/.local/lib/python3.7/site-packages/fiona/collection.py", line 162, in __init__
self.session.start(self, **kwargs)File "fiona/ogrext.pyx", line 540, in fiona.ogrext.Session.startFile "fiona/_shim.pyx", line 81, in fiona._shim.gdal_open_vector
Yeah, I’ve messed with GDAL and the like in a previous job, not so fun.
Keep in mind that you can also specify a packages.txt file, to add system-level dependencies. Maybe start by installing GDAL on the image and see if that gets you somewhere:
Thanks Randy - I appreciate the response, and bonus points for not making me feel like a total idiot on here
i really dig streamlit and hope i can do something helpful with it… it’s a great tool and an amazing step in the right direction!
ok - i’ve been going through the packages.txt file stuff & could use some documentation there? if i need to add the repository to apt-get install gdal i’m not sure how to do that?
i definitely think i need gdal & more than that libspatialindex for analyzing geospatial data regardless…
i’ve used this repository to set up the back end for jupyter notebooks? any thoughts
I would start by removing the two lines that are there and instead putting gdal-bin on its own line and seeing what happens. In general, you should try to find things that are already binaries that can be installed by apt, I don’t think we currently make any functionality available for running make or other compilation steps.
After cloning your app, it appears that you don’t even need to install gdal…see my changes here:
It appears all you need to do is add pygeos to your requirements.txt file, and you can remove everything from your requires.txt (which will speed up deployment)
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.