Python 프로젝트 만들기 예시 - glasslego/getting-started-with-python GitHub Wiki
- Homebrew는 macOS와 Linux에서 사용할 수 있는 패키지 관리자
- macOS에서 명령어 한 줄로 소프트웨어 설치, 업데이트, 삭제 가능
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# 설치 확인
brew --version
# Git 설치
brew install git
# Python 설치
brew install python
# GUI 앱 설치 (예: Google Chrome)
brew install --cask google-chrome
# 설치된 패키지 업데이트
brew update && brew upgrade
# 설치된 패키지 제거
brew uninstall python
brew install uv
# python 설치
uv python install 3.10
uv python install 3.11
uv python install 3.12
# 설치된 python 확인 (UV가 설치한 Python + 시스템에서 발견된 Python들)
uv python list --only-installed
- 가상환경이 필요한 이유?
- 각 프로젝트 별 독립된 파이썬 공간(작업실)
- (파이썬 프로젝트를 할 때 가상 환경을 사용하는 것은 필수)
내 컴퓨터
├── 프로젝트A 가상환경 python3.9(pandas 1.3.0, numpy 1.20.0)
├── 프로젝트B 가상환경 python3.10(pandas 2.0.0, numpy 1.24.0)
└── 프로젝트C 가상환경 python3.11(pyspark 3.4.0, pandas 1.5.0)
# 프로젝트 디렉토리
cd getting-started-with-python
# 가상환경 생성
uv venv --python 3.11
#Using CPython 3.11.13
#Creating virtual environment at: .venv
#Activate with: source .venv/bin/activate
# -m은 특정 모듈(module)을 스크립트처럼 실행하라는 의미
# python3.11 -m venv .venv
# 가상환경 activate
source .venv/bin/activate
# deactivate
deactivate
# 프로젝트 초기화
uv init
Poetry | UV | 참고 |
---|---|---|
poetry | uv | |
poetry add | uv add | |
poetry config virtualenvs.in-project true poetry env use |
uv venv | 현재 디렉토리 아래 .venv 디렉토리에 가상환경을 생성합니다. |
poetry env use [python executable path] | uv venv --python [python version] | 가상환경에서 사용할 python (버전)을 지정합니다. |
poetry init | uv init | |
poetry install | uv sync --frozen | uv.lock을 업데이트하지 않고 설치할 경우 --frozen 옵션을 사용합니다. |
poetry remove | uv remove | |
poetry run | uv run | |
poetry show --tree | uv tree | |
poetry update | uv sync |