- [Streamlit] 개발환경 구축하기2024년 01월 29일 19시 21분 38초에 업로드 된 글입니다.작성자: 묭동이
안녕하세요 이번 글에서는 Streamlit과 Streamlit 개발환경 구축 방법에 대해서 알아보도록 하겠습니다.
Streamlit
- Streamlit은 Data Science, Machine learning 등을 위한 웹 애플리케이션을 쉽게 만들 수 있는 오픈소스 Python 라이브러리
- 복잡한 프론트엔드 지식 없이도 빠르게 대화형 웹 앱을 구축하고 배포할 수 있습니다.
- 데이터 시각화, 인터랙티브 위젯, 실시간 데이터 탐색 등의 기능을 Python 코드로 간편하게 구현할 수 있습니다.
Streamlit 개발환경 구축하기
1. 가상환경 구축하기
python에서 가상환경 구축시 가장 많이 사용하는 것으로 conda와 virtualenv가 있는데요
1-1에서는 conda로 가상환경 만드는 방법을 1-2에서는 virtualenv로 가상환경 만드는 방법에 대해서 말씀드리도록 하겠습니다.
1-1 conda 가상환경 구축하기
- 구축 명령어 : conda create -n 가상환경이름 python='설치하고자하는 파이썬 버전'
- Ex) 가상환경이름 : py38 python 버전: 3.8
- conda creat -n py38 python=3.8
- Ex) 가상환경이름 : py38 python 버전: 3.8
- 실행 명령어 : conda activate "실행하고자 하는 가상환경명"
- Ex) py38 가상환경 실행
- conda activate py38
- Ex) py38 가상환경 실행
제 블로그에서 conda 환경 구축에 대해서 다룬 내용이 있어서 한번 보셔도 좋을 것 같습니다 :)
[Python] Anaconda 가상환경 구축(macos)
가상환경 ? 독립된 공간에서 Python 프로젝트와 의존성들을 관리하기 위해 사용 가상환경을 사용하는 이유 1. 의존성 관리 : 프로젝트마다 다른 버전의 라이브러리를 사용할 수 있음 2. 환경 분리 :
vamos-dev.tistory.com
1-2 virtualenv 가상환경 구축하기
- 구축 명령어 : python3 venv -m "가상환경이름"
- Ex) 가상환경이름 : test
- python3 venv -m test
- Ex) 가상환경이름 : test
- 실행 명령어 : source "실행하고자하는 가상환경명"/bin/activate
- Ex) test 가상환경 실행
- source test/bin/activate
- Ex) test 가상환경 실행
2. streamlit 설치하기
- 가상환경을 활성화시킨 후 아래 명령어를 통해 streamlit 라이브러리를 설치해줍니다.
pip install streamlit
3. streamlit 실행하기
- streamlit을 정상적으로 설치한 후 간단한 테스트 파일을 만든 후 아래 명령어를 통해 streamlit을 실행합니다.
streamlit run (실행하고자하는 파일명)
먼저 간단하게 test.py 파일을 만든 후 안에 streamlit 버전을 출력하는 코드를 아래와 같이 작성해주도록 하겠습니다.
- test.py
import streamlit as st def main(): st.title('Welcome Streamlit') st_version = st.__version__ st.write(f'streamlit version: {st_version}') if __name__ == "__main__": main()
이후 아래 명령어를 통해 streamlit 라이브러리를 통해 test.py 파일을 실행해주도록 하겠습니다.
streamlit run test.py
그러면 아래와 같이 파일이 정상적으로 실행되고 버전도 잘 출력되는 것을 확인할 수 있습니다 :)
Reference
Streamlit Docs
Join the community Streamlit is more than just a way to make data apps, it's also a community of creators that share their apps and ideas and help each other make their work better. Please come join us on the community forum. We love to hear your questions
docs.streamlit.io
venv — Creation of virtual environments
Source code: Lib/venv/ The venv module supports creating lightweight “virtual environments”, each with their own independent set of Python packages installed in their site directories. A virtual en...
docs.python.org
다음글이 없습니다.이전글이 없습니다.댓글