How to install Streamlit?

To install Streamlit, you can use Python's package manager, pip. Streamlit is a Python library for creating web applications for data science and machine learning. Lets work on below the steps to setup streamlit workspace.

1. Install Python:

If you haven't already, you need to install Python on your system. You can download Python from the official website: https://www.python.org/downloads/

2. Create a Virtual Environment (Optional but Recommended):

It's a good practice to create a virtual environment to isolate your Streamlit project from other Python projects. You can create a virtual environment using the following commands:

bash
# On Windows
python -m venv streamlit-env
# On macOS and Linux
python3 -m venv streamlit-env        

Activate the virtual environment:

bash
# On Windows
streamlit-env\Scripts\activate
# On macOS and Linux
source streamlit-env/bin/activate        

3. Install Streamlit:

Once you have your virtual environment (or if you choose not to use one), you can install Streamlit using pip:

bash 
pip install streamlit        

4. Verify Installation:

You can verify that Streamlit has been installed correctly by running the following command:

bash 
streamlit --version        

This should display the installed Streamlit version.

5. Create Your First Streamlit App:

Now that Streamlit is installed, you can create your first Streamlit app by creating a Python script (e.g., my_app.py) and adding your Streamlit code. For example:

python 
import streamlit as st 

st.title('My First Streamlit App') 
st.write('Hello, Streamlit!')        

Save the file and then run it using the following command:

bash 
streamlit run my_app.py        

This command will launch a local web server and open your Streamlit app in a web browser.

You can now start building interactive data apps with Streamlit by adding various widgets and data visualizations to your app.

Remember to deactivate your virtual environment when you're done working on your Streamlit app:

bash 
deactivate? # On Windows 

bash 
source deactivate? # On macOS and Linux        

要查看或添加评论,请登录

Sankar R.的更多文章

社区洞察

其他会员也浏览了