sai-lohith/streamlit_docs huggingface dataset:
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceremovePAGE ELEMENTSWrite and magicaddText elementsaddData elementsaddChart elementsaddInput widgetsaddMedia elementsaddLayouts and containersaddChat elementsaddStatus elementsaddThird-party componentsopen_in_newAPPLICATION LOGICNavigation and pagesaddExecution flowaddCaching and stateaddConnections and secretsaddCustom componentsremovest.components.v1​.declare_componentst.components.v1.htmlst.components.v1.iframeUtilitiesaddConfigurationaddTOOLSApp testingaddCommand lineaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Develop/API reference/Custom componentsCustom components
Declare a componentCreate and register a custom component.st.components.v1.declare_component(
    "custom_slider",
    "/frontend",
)
HTMLDisplay an HTML string in an iframe.st.components.v1.html(
    "<p>Foo bar.</p>"
)
iframeLoad a remote URL in an iframe.st.components.v1.iframe(
    "docs.streamlit.io"
)
Previous: Connections and secretsNext: st.components.v1​.declare_componentforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Knowledge base/FAQ/How to download a Pandas DataFrame as a CSV?How to download a Pandas DataFrame as a CSV?
Use the st.download_button widget that is natively built into Streamlit. Check out a sample app demonstrating how you can use st.download_button to download common file formats.
Example usage
import streamlit as st
import pandas as pd

df = pd.read_csv("dir/file.csv")

@st.experimental_memo
def convert_df(df):
   return df.to_csv(index=False).encode('utf-8')


csv = convert_df(df)

st.download_button(
   "Press to Download",
   csv,
   "file.csv",
   "text/csv",
   key='download-csv'
)

Additional resources:

https://blog.streamlit.io/0-88-0-release-notes/
https://streamlit-release-demos-0-88streamlit-app-0-88-v8ram3.streamlit.app/
https://docs.streamlit.io/develop/api-reference/widgets/st.download_button
Previous: How to download a file in Streamlit?Next: How do I get dataframe row-selections from a user?forumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationremoveUse command lineUse Anaconda DistributionUse GitHub CodespacesUse SnowflakeFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Get started/InstallationInstall Streamlit
There are multiple ways to set up your development environment and install Streamlit. Read below to
understand these options. Developing locally with Python installed on your own computer is the most
common scenario.
Summary for experts

Set up your Python development environment.
Run:
pip install streamlit


Validate the installation by running our Hello app:
streamlit hello


Jump to our Basic concepts.

Installation steps for the rest of us
Option 1: I'm comfortable with the command lineInstall Streamlit on your own machine using tools like venv and pip.Option 2: I prefer a graphical interfaceInstall Streamlit using the Anaconda Distribution graphical user interface. This is also the best
approach if you're on Windows or don't have Python set up.Option 3: I'd rather use a cloud-based environmentUse Streamlit Community Cloud with GitHub Codespaces so you don't have to go through the trouble
of installing Python and setting up an environment.Option 4: I need something secure, controlled, and in the cloudUse Streamlit in Snowflake to code your apps in the cloud, right alongside your
data with role-based access controls.Previous: Get startedNext: Use command lineforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceremovePAGE ELEMENTSWrite and magicaddText elementsaddData elementsaddChart elementsaddInput widgetsaddMedia elementsaddLayouts and containersaddChat elementsaddStatus elementsremoveCALLOUTSst.successst.infost.warningst.errorst.exceptionOTHERst.progressst.spinnerst.statusst.toastst.balloonsst.snowThird-party componentsopen_in_newAPPLICATION LOGICNavigation and pagesaddExecution flowaddCaching and stateaddConnections and secretsaddCustom componentsaddUtilitiesaddConfigurationaddTOOLSApp testingaddCommand lineaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Develop/API reference/Status elements/st.warningst.warningStreamlit VersionVersion 1.34.0Version 1.33.0Version 1.32.0Version 1.31.0Version 1.30.0Version 1.29.0Version 1.28.0Version 1.27.0Version 1.26.0Version 1.25.0Version 1.24.0Version 1.23.0Version 1.22.0Version 1.21.0Version 1.20.0Version 1.19.0Version 1.18.0Version 1.17.0Version 1.16.0Version 1.15.0Version 1.14.0Version 1.13.0Streamlit in SnowflakeDisplay warning message.
Function signature[source] st.warning(body, *, icon=None) Parameters

body
(str)

 
The warning text to display.


icon
(str, None)

 
An optional emoji or icon to display next to the alert. If icon
is None (default), no icon is displayed. If icon is a
string, the following options are valid:

A single-character emoji. For example, you can set icon="🚨"
or icon="🔥". Emoji short codes are not supported.

An icon from the Material Symbols library (outlined style) in the
format ":material/icon_name:" where "icon_name" is the name
of the icon in snake case.
For example, icon=":material/thumb_up:" will display the
Thumb Up icon. Find additional icons in the Material Symbols
font library.


Example

import streamlit as st

st.warning('This is a warning', icon="⚠️")


Previous: st.infoNext: st.errorforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceremovePAGE ELEMENTSWrite and magicaddText elementsaddData elementsaddChart elementsaddInput widgetsaddMedia elementsaddLayouts and containersaddChat elementsaddStatus elementsaddThird-party componentsopen_in_newAPPLICATION LOGICNavigation and pagesremovest.page_linklinkst.switch_pageExecution flowaddCaching and stateaddConnections and secretsaddCustom componentsaddUtilitiesaddConfigurationaddTOOLSApp testingaddCommand lineaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Develop/API reference/Navigation and pagesNavigation and pages
Page linkDisplay a link to another page in a multipage app.st.page_link("app.py", label="Home", icon="🏠")
st.page_link("pages/profile.py", label="Profile")
Switch pageProgrammatically navigates to a specified page.st.switch_page("pages/my_page.py")
Previous: Third-party componentsNext: st.page_linkforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceremovePAGE ELEMENTSWrite and magicaddText elementsremoveHEADINGS & BODYst.titlest.headerst.subheaderst.markdownFORMATTED TEXTst.captionst.codest.dividerst.echost.latexst.textData elementsaddChart elementsaddInput widgetsaddMedia elementsaddLayouts and containersaddChat elementsaddStatus elementsaddThird-party componentsopen_in_newAPPLICATION LOGICNavigation and pagesaddExecution flowaddCaching and stateaddConnections and secretsaddCustom componentsaddUtilitiesaddConfigurationaddTOOLSApp testingaddCommand lineaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Develop/API reference/Text elements/st.titlest.titleStreamlit VersionVersion 1.34.0Version 1.33.0Version 1.32.0Version 1.31.0Version 1.30.0Version 1.29.0Version 1.28.0Version 1.27.0Version 1.26.0Version 1.25.0Version 1.24.0Version 1.23.0Version 1.22.0Version 1.21.0Version 1.20.0Version 1.19.0Version 1.18.0Version 1.17.0Version 1.16.0Version 1.15.0Version 1.14.0Version 1.13.0Streamlit in SnowflakeDisplay text in title formatting.
Each document should have a single st.title(), although this is not
enforced.
Function signature[source] st.title(body, anchor=None, *, help=None) Parameters

body
(str)

 
The text to display as Github-flavored Markdown. Syntax
information can be found at: https://github.github.com/gfm.
This also supports:

Emoji shortcodes, such as :+1:  and :sunglasses:.
For a list of all supported codes,
see https://share.streamlit.io/streamlit/emoji-shortcodes.
LaTeX expressions, by wrapping them in "$" or "$$" (the "$$"
must be on their own lines). Supported LaTeX functions are listed
at https://katex.org/docs/supported.html.
Colored text and background colors for text, using the syntax
:color[text to be colored] and :color-background[text to be colored],
respectively. color must be replaced with any of the following
supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
For example, you can use :orange[your text here] or
:blue-background[your text here].



anchor
(str or False)

 
The anchor name of the header that can be accessed with #anchor
in the URL. If omitted, it generates an anchor using the body.
If False, the anchor is not shown in the UI.


help
(str)

 
An optional tooltip that gets displayed next to the title.
Examples

import streamlit as st

st.title('This is a title')
st.title('_Streamlit_ is :blue[cool] :sunglasses:')

Built with Streamlit 🎈Fullscreen open_in_new

Previous: Text elementsNext: st.headerforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceremovePAGE ELEMENTSWrite and magicaddText elementsaddData elementsaddChart elementsaddInput widgetsaddMedia elementsaddLayouts and containersaddChat elementsaddStatus elementsaddThird-party componentsopen_in_newAPPLICATION LOGICNavigation and pagesaddExecution flowremovest.dialogst.formst.form_submit_buttonst.fragmentst.rerunst.stopCaching and stateaddConnections and secretsaddCustom componentsaddUtilitiesaddConfigurationaddTOOLSApp testingaddCommand lineaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Develop/API reference/Execution flow/st.stopst.stopStreamlit VersionVersion 1.34.0Version 1.33.0Version 1.32.0Version 1.31.0Version 1.30.0Version 1.29.0Version 1.28.0Version 1.27.0Version 1.26.0Version 1.25.0Version 1.24.0Version 1.23.0Version 1.22.0Version 1.21.0Version 1.20.0Version 1.19.0Version 1.18.0Version 1.17.0Version 1.16.0Version 1.15.0Version 1.14.0Version 1.13.0Streamlit in SnowflakeStops execution immediately.
Streamlit will not run any statements after st.stop().
We recommend rendering a message to explain why the script has stopped.
Function signature[source] st.stop() Example

import streamlit as st

name = st.text_input('Name')
if not name:
  st.warning('Please input a name.')
  st.stop()
st.success('Thank you for inputting a name.')


Previous: st.rerunNext: st.experimental_rerunforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudremoveGet startedaddDeploy your appaddManage your appremoveApp analyticsApp settingsDelete your appEdit your appFavorite your appReboot your appShare your appaddManage your accountaddTroubleshootingStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Deploy/Streamlit Community Cloud/Manage your app/App settingsApp settings
This page is about your app settings on Streamlit Community Cloud. From your app settings you can view or modify your app's URL, manage public or private access to your apps and update your saved secrets for your apps.
If you access "Settings" from your App menu in the upper-right corner of your running app, you can access features to control the appearance of your app while its running.
Access your app settings
You can get to your app's settings:

From your workspace.
From your Cloud logs.

Access app settings from your workspace
From your workspace at share.streamlit.io, click the overflow icon (more_vert) next to your app. Click "Settings".

Access app settings from your Cloud logs
From your app at <your-custom-subdomain>.streamlit.app, click "Manage app" in the lower-right corner.

Click the overflow menu icon (more_vert) and click "Settings".

Change your app settings
View or change your app's URL
Read more about Custom subdomains.

Update your app's share settings
Learn how to Share your app.

Update your secrets
Learn more about Secrets management.
Previous: App analyticsNext: Delete your appforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsremoveDependenciesSecretsStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Deploy/Concepts/SecretsManaging secrets when deploying your app
If you are connecting to data sources or external services, you will likely be handling secret information like credentials or keys. Secret information should be stored and transmitted in a secure manner. When you deploy your app, ensure that you understand your platform's features and mechanisms for handling secrets so you can follow best practice.
Avoid saving secrets directly in your code and keep .gitignore updated to prevent accidentally committing a local secret to your repository. For helpful reminders, see Security reminders.
If you are using Streamlit Community Cloud, Secrets management allows you save environment variables and store secrets outside of your code. If you are using another platform designed for Streamlit, check if they have a built-in mechanism for working with secrets. In some cases, they may even support st.secrets or securely uploading your secrets.toml file.
For information about using st.connection with environment variables, see Global secrets, managing multiple apps and multiple data stores.Previous: DependenciesNext: Streamlit Community CloudforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Knowledge base/Installing dependencies/ModuleNotFoundError No module namedModuleNotFoundError: No module named
Problem
You receive the error ModuleNotFoundError: No module named when you deploy an app on Streamlit Community Cloud.
Solution
This error occurs when you import a module on Streamlit Community Cloud that isn’t included in your requirements file. Any external Python dependencies that are not distributed with a standard Python installation should be included in your requirements file.
E.g. You will see ModuleNotFoundError: No module named 'sklearn' if you don’t include scikit-learn in your requirements file and import sklearn in your app.
Related forum posts:

https://discuss.streamlit.io/t/getting-error-modulenotfounderror-no-module-named-beautifulsoup/9126
https://discuss.streamlit.io/t/modulenotfounderror-no-module-named-vega-datasets/16354
Previous: ImportError libGL.so.1 cannot open shared object file No such file or directoryNext: ERROR No matching distribution found forforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Knowledge base/FAQ/Widget updating for every second input when using session stateWidget updating for every second input when using session state
Overview
You are using session state to store page interactions in your app. When users interact with a widget in your app (e.g., click a button), you expect your app to update its widget states and reflect the new values. However, you notice that it doesn't. Instead, users have to interact with the widget twice (e.g., click a button twice) for the app to show the correct values. What do you do now? 🤔 Let's walk through the solution in the section below.
Solution
When using session state to update widgets or values in your script, you need to use the unique key you assigned to the widget, not the variable that you assigned your widget to. In the example code block below, the unique key assigned to the slider widget is slider, and the variable the widget is assigned to is slide_val.
Let's see this in an example. Say you want a user to click a button that resets a slider.
To have the slider's value update on the button click, you need to use a callback function with the on_click parameter of st.button:
# the callback function for the button will add 1 to the
# slider value up to 10
def plus_one():
    if st.session_state["slider"] < 10:
        st.session_state.slider += 1
    else:
        pass
    return

# when creating the button, assign the name of your callback
# function to the on_click parameter
add_one = st.button("Add one to the slider", on_click=plus_one, key="add_one")

# create the slider
slide_val = st.slider("Pick a number", 0, 10, key="slider")

Relevant resources

Caching Sqlite DB connection resulting in glitchy rendering of the page
Select all checkbox that is linked to selectbox of options
Previous: Where does st.file_uploader store uploaded files and when do they get deleted?Next: Why does Streamlit restrict nested st.columns?forumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Knowledge base/FAQ/Where does st.file_uploader store uploaded files and when do they get deleted?Where does st.file_uploader store uploaded files and when do they get deleted?
When you upload a file using st.file_uploader, the data are copied to the Streamlit backend via the browser, and contained in a BytesIO buffer in Python memory (i.e. RAM, not disk). The data will persist in RAM until the Streamlit app re-runs from top-to-bottom, which is on each widget interaction. If you need to save the data that was uploaded between runs, then you can cache it so that Streamlit persists it across re-runs.
As files are stored in memory, they get deleted immediately as soon as they’re not needed anymore.
This means Streamlit removes a file from memory when:

The user uploads another file, replacing the original one
The user clears the file uploader
The user closes the browser tab where they uploaded the file

Related forum posts:

https://discuss.streamlit.io/t/streamlit-sharing-fileupload-where-does-it-go/9267
https://discuss.streamlit.io/t/how-to-update-the-uploaded-file-using-file-uploader/13512/
Previous: What browsers does Streamlit support?Next: Widget updating for every second input when using session stateforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy