{"id":7766,"library":"streamlit-folium","title":"Streamlit-Folium","description":"Streamlit-Folium seamlessly integrates the Folium mapping library into Streamlit applications, allowing users to render interactive geospatial visualizations. It provides both a bi-directional component, `st_folium()`, for enhanced user interaction and a static renderer, `folium_static()`. The library is actively maintained, with its current version 0.27.1 released on March 26, 2026, indicating a consistent release cadence.","status":"active","version":"0.27.1","language":"en","source_language":"en","source_url":"https://github.com/randyzwitch/streamlit-folium","tags":["streamlit","folium","mapping","geospatial","interactive","visualization"],"install":[{"cmd":"pip install streamlit-folium","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for the Streamlit application framework.","package":"streamlit","optional":false},{"reason":"The core mapping library rendered by streamlit-folium.","package":"folium","optional":false},{"reason":"Templating engine, a dependency of Folium/Streamlit rendering.","package":"jinja2","optional":false},{"reason":"Part of the Folium ecosystem for rendering elements.","package":"branca","optional":false}],"imports":[{"note":"The primary bi-directional component for interactive maps.","symbol":"st_folium","correct":"from streamlit_folium import st_folium"},{"note":"This is a convenience function for static rendering, less interactive than `st_folium`.","wrong":"import streamlit_folium.folium_static","symbol":"folium_static","correct":"from streamlit_folium import folium_static"}],"quickstart":{"code":"import streamlit as st\nimport folium\nfrom streamlit_folium import st_folium\n\nst.set_page_config(layout=\"wide\")\n\nm = folium.Map(location=[39.949610, -75.150282], zoom_start=16)\n\nfolium.Marker(\n    [39.949610, -75.150282],\n    popup=\"Liberty Bell\",\n    tooltip=\"Liberty Bell\"\n).add_to(m)\n\nst_data = st_folium(m, width=725)","lang":"python","description":"This example initializes a Folium map centered on the Liberty Bell, adds a marker, and then renders it in a Streamlit application using the `st_folium` component, which enables bi-directional interaction. The `st_data` variable captures interaction events from the map."},"warnings":[{"fix":"Use a `with` block: `with col: folium_static(m)`.","message":"Using `folium_static()` within Streamlit columns (e.g., `col.folium_static(m)`) can raise a `StreamlitAPIException`. Components directly exposed by Streamlit (`st.`) cannot be called on column objects in this manner.","severity":"gotcha","affected_versions":"<=0.27.1"},{"fix":"Migrate from `folium_static(m)` to `st_folium(m)` to leverage interactive features and pass data back to Streamlit.","message":"The `st_folium()` component is generally preferred over `folium_static()` for modern Streamlit apps due to its bi-directional communication, allowing map interactions (clicks, zooms) to be passed back to Python. `folium_static()` only renders a static HTML representation.","severity":"breaking","affected_versions":"All versions"},{"fix":"Ensure `streamlit-folium` (and `folium`) are correctly installed in your deployment environment. Restart the app/terminal. Check for restrictive firewalls or proxy settings, especially in corporate networks.","message":"Deployment issues often stem from frontend assets not loading correctly for `streamlit-folium` components, leading to errors like 'Your app is having trouble loading the streamlit_folium.st_folium component.'. This can be due to improper installation or network/proxy configurations.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your project uses Python 3.11 or newer to avoid compatibility issues.","message":"Python 3.10 support was dropped in recent versions (e.g., v0.27.0).","severity":"deprecated","affected_versions":">=0.27.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install folium streamlit-folium` to ensure both libraries are present and compatible. Verify your `requirements.txt` if deploying.","cause":"Either `folium` or `streamlit-folium` (which depends on `folium`) is not installed in the environment where the Streamlit app is running, or there's a version conflict.","error":"ModuleNotFoundError: No module named 'folium'"},{"fix":"Wrap the component call in a `with` block for the layout element: `with col: folium_static(m)` or `with col: st_folium(m)`.","cause":"You are attempting to call `folium_static` directly on a Streamlit layout element (e.g., `col.folium_static(m)`), which is not how custom components interact with layout objects.","error":"StreamlitAPIException: folium_static() is not a valid Streamlit command."},{"fix":"Try `pip install --upgrade streamlit-folium` to ensure all assets are correctly installed. Clear your browser cache or try a different browser. If deploying, check network configurations.","cause":"Streamlit's frontend assets for `streamlit-folium` are failing to load, often due to an incomplete installation, caching issues, or network/proxy restrictions.","error":"Randomly get \"Your app is having trouble loading the streamlit_folium.st_folium component.\" Had to reboot."},{"fix":"Check the `streamlit-folium` GitHub issues for specific fixes or workarounds. This often requires updating `streamlit-folium` or `folium` to a version with a patch, or adjusting how MarkerCluster is initialized.","cause":"Compatibility issues between `folium.plugins.MarkerCluster` and newer Streamlit versions or `streamlit-folium`.","error":"MarkerCluster not working properly in Streamlit 1.34 onwards"}]}