728x90
반응형

 

1. Streamlit 설치하기

먼저, Streamlit을 설치 합니다. 이를 위해 Python이 설치되어 있어야 하며, Python 3.6 이상 버전을 사용하는 것이 좋습니다. Python이 설치되어 있다면, 다음과 같은 명령어를 통해 Streamlit을 설치할 수 있습니다.

$ python -V
Python 3.6.8
$ pip -V
pip 21.3.1 from <user>.local/lib/python3.6/site-packages/pip (python 3.6)
$ pip install streamlit
Defaulting to user installation because normal site-packages is not writeable
Collecting streamlit
  Downloading streamlit-1.10.0-py2.py3-none-any.whl (9.1 MB)
     |████████████████████████████████| 9.1 MB 24.5 MB/s   

... <생략>
Successfully installed altair-4.1.0 blinker-1.5 commonmark-0.9.1 gitdb-4.0.9 \
gitpython-3.1.18 pyarrow-6.0.1 pydeck-0.6.2 pympler-1.0.1 rich-12.6.0 semver-2.13.0 \
smmap-5.0.0 streamlit-1.10.0 toolz-0.12.0 validators-0.20.0 watchdog-2.3.1

 

2. Streamlit 데모 실행하기

Streamlit이 성공적으로 설치되었다면, Streamlit의 데모를 실행해 볼 수 있습니다. 이는 Streamlit이 제대로 설치되었는지 확인하는 데에도 도움이 됩니다. 다음 명령어를 통해 Streamlit의 Hello World 데모를 실행할 수 있습니다.

 

$ streamlit hello

  Welcome to Streamlit. Check out our demo in your browser.

  Network URL: http://<Private IP>:8501

  Ready to create your own Python apps super quickly?
  Head over to https://docs.streamlit.io

  May you create awesome apps!
 

이 명령어를 실행하면, 기본 웹 브라우저가 자동으로 열리고 Streamlit의 환영 메시지가 담긴 페이지로 이동합니다. 이 페이지에서는 Streamlit의 다양한 기능을 소개하는 예제들을 확인하고 직접 실행해 볼 수 있습니다.

3. 자신만의 Streamlit 앱 만들기

Streamlit으로 자신만의 앱을 만들기 위해서는 간단한 Python 스크립트를 작성해야 합니다. 예를 들어, 다음과 같은 코드를 app.py라는 파일에 작성해 보세요.

 

import streamlit as st

st.title('나의 첫 Streamlit 앱')
st.write('Streamlit은 정말 멋져요!')

 

그리고 나서, 터미널에서 다음과 같이 이 스크립트를 실행합니다.

$ streamlit run app.py
2024-03-13 14:08:43.872 Did not auto detect external IP.
Please go to https://docs.streamlit.io/ for debugging hints.

  You can now view your Streamlit app in your browser.

  Network URL: http://<Private IP>:8501

 

이 명령어를 실행하면, 웹 브라우저가 열리고 당신이 작성한 Streamlit 앱을 볼 수 있습니다. 이제부터는 원하는 대로 코드를 수정하고, 데이터를 시각화하고, 사용자 입력을 받는 등 다양한 기능을 추가하여 앱을 개발할 수 있습니다.

 

마무리

Streamlit을 사용하면 복잡한 웹 프레임워크 없이도 Python만으로 데이터 애플리케이션을 빠르게 구축할 수 있습니다. 이제 기본적인 설치와 데모 실행 방법을 알게 되었으니, 다양한 프로젝트에 활용해 보겠습니다.

 
728x90
반응형

+ Recent posts