---
title: "#재현성 #파이썬 #생태계 #도구 ¤pyenv ¤poetry ¤poethepoet"
url: "https://notes.junghanacs.com/notes/20250630T104430"
author: "Junghan Kim"
date: "2025-06-30T10:44:00+09:00"
lastmod: "2025-06-30T00:00:00+09:00"
tags: ["bib","python","reproducibility","packages","virtual","llmops","mlops","version","management"]
description: "pyenv와 poetry, poethepoet를 묶어 파이썬 작업 환경의 재현성과 버전 관리를 어떻게 챙길지 정리한다."
---

> [!abstract] 이 노트에 대하여
> 
> 재현성을 기준으로 pyenv와 poetry, poethepoet 같은 파이썬 생태계 도구를 정리한다. 버전 관리와 가상환경, ML/LLMOps 맥락을 함께 고려하는 노트다.

-   **Pyenv+Poetry** 재현성 중시 Python 프로젝트

## 히스토리

-   [2025-06-30 Mon 15:48] llm.org 파일 알지? 문서 파일에 바로 작성 할거야. 참고해
-   [2025-06-30 Mon 10:44] Created!
-   [@폴이우수틴 LLM 엔지니어링 RAG, 파인튜닝, LLMOps](https://notes.junghanacs.com/bib/20250629T112345)
-   [#파이썬: ¤미니콘다 ¤miniconda ¤anaconda](https://notes.junghanacs.com/notes/20240625T153507)
-   [#파이썬 #패키지관리 #가상환경 #비교 ¤pyenv ¤conda ¤mamba ¤venv ¤uv - 레거시 호환](https://notes.junghanacs.com/notes/20250217T142822)
-   [@astral-sh ¤uv 러스트 고속 파이썬 가상환경 이맥스](https://notes.junghanacs.com/notes/20250214T134943)
-   [#모음: #파이썬 #생태계 #모듈](https://notes.junghanacs.com/notes/20250214T141826)

## 관련메타

-   [†#스크립트쉘¤bash¤zsh](https://notes.junghanacs.com/meta/20221121T132700)
-   [†#버전](https://notes.junghanacs.com/meta/20240821T162824)

## BIBLIOGRAPHY

- “Poe the Poet Documentation.” n.d. Accessed June 30, 2025. <https://poethepoet.natn.io/index.html>.
- “Poetry - Python Dependency Management and Packaging Made Easy.” n.d. Accessed June 29, 2025. <https://python-poetry.org/>.
- “Pyenv/Pyenv.” 2025. <https://github.com/pyenv/pyenv>.

## 2025 Pyenv/Pyenv

([“Pyenv/Pyenv” 2025](https://notes.junghanacs.com/notes/20250630T104430#citeproc_bib_item_3))

Simple Python version management

### 설치

```shell

curl -fsSL https://pyenv.run | bash
```

#### 설정 zsh

```shell
echo 'export PYENV_ROOT="HOME/.pyenv"' >> ~/.zshrc
echo '[[ -d PYENV_ROOT/bin ]] && export PATH="PYENV_ROOT/bin:PATH"' >> ~/.zshrc
echo 'eval "(pyenv init - zsh)"' >> ~/.zshrc
```

## 2025 Poetry - Python Dependency Management and Packaging Made Easy

([“Poetry - Python Dependency Management and Packaging Made Easy” n.d.](https://notes.junghanacs.com/notes/20250630T104430#citeproc_bib_item_2))

## 2025 Poe the Poet Documentation

([“Poe the Poet Documentation” n.d.](https://notes.junghanacs.com/notes/20250630T104430#citeproc_bib_item_1))

-   Poe the Poet is a batteries included task runner that works well with poetry or with uv.
-   Poe the Poet는 poetry 또는 uv와 잘 작동하는 배터리 포함(task runner) 도구입니다.

-   It provides a simple way to define project tasks within your pyproject.toml, and either a standalone CLI or a poetry plugin to run them using your project's virtual environment.
-   `pyproject.toml` 내에서 프로젝트 작업을 간단히 정의할 수 있으며, 독립 실행형 CLI 또는 poetry 플러그인을 통해 프로젝트의 가상 환경(virtual environment)에서 작업을 실행할 수 있습니다.
-   "Simple things should be simple, complex things should be possible." – Alan Kay

### Poetry plugin 플러그인 ¶

-   The poethepoet poetry plugin offers tighter integration with the poetry CLI.
-   poethepoet 시(poetry) 플러그인은 poetry CLI와 더 긴밀한 통합을 제공합니다.



```shell
poetry self add 'poethepoet[poetry_plugin]'
```

## poetry 특정 버전을 설치하도록 명시 하는 방법

[2025-06-30 Mon 16:08] 하단 참고

```shell
curl -sSL https://install.python-poetry.org | python3 - --version 1.8.3
```

## Pyenv + Poetry 설치 가이드

[2025-06-30 Mon 15:52]

참고 할 것

### 1. Pyenv 설정

```shell
# Pyenv 설치 (이미 있으면 생략)
curl -fsSL https://pyenv.run | bash

# 필요한 빌드 도구 설치 (Ubuntu 예시)
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

# Python 설치 (예: 3.10.12)
pyenv install 3.10.12
```

### 2. Poetry 설치

```shell
# 공식 설치 스크립트 사용 (권장)
curl -sSL https://install.python-poetry.org | python3 -

# PATH 설정 (~/.zshrc 또는 ~/.bashrc에 추가)
export PATH="HOME/.local/bin:PATH"

# ~/git/junghan0611/llm-twin main !2 ?2 via 🐍 v3.11.8
# ➜ whereis poetry
# poetry: /home/tbdhny/.local/bin/poetry
# ~/git/junghan0611/llm-twin main !2 ?2 via 🐍 v3.11.8
```

#### 로그

### 3. 프로젝트 시작

```shell
# Python 버전 지정
pyenv local 3.10.12

# 새 프로젝트 생성
poetry new my_project
cd my_project

# 가상환경 생성 및 활성화
poetry install
poetry shell

# 패키지 추가 (예: PyTorch)
poetry add torch@latest --group main
```

### _주의사항_ - poetry.lock

-   `poetry.lock` 파일은 반드시 버전 관리 시스템(Git)에 포함시킬 것
-   `pyproject.toml` 에 Python 버전 제약 조건 명시 예: \#+begin_src toml [tool.poetry.dependencies] python = "^3.10"

#### @user

## **결론: 선택 가이드**

| **도구**         | **MLOps/LLMOps 추천도** | **주요 사용 케이스** |
|----------------|----------------------|---------------|
| **Miniconda**    | ⭐⭐⭐⭐             | GPU/ML 연구, 복잡한 종속성 |
| **Pyenv+Poetry** | ⭐⭐⭐               | 재현성 중시 Python 프로젝트 |
| **UV**           | ⭐⭐ (아직 성장 중)  | 고속 빌드가 필요한 환경 |
|                  |                      |                    |

-   **Conda** 는 "ML 연구 단계"에서 유리하지만, **Poetry** 는 "프로덕션 배포"에 강점.
-   **UV** 는 성능 면에서 유망하지만, 아직 MLOps 생태계 지원이 약함.

## 로그

### [2025-06-30](https://notes.junghanacs.com/journal/20250630T000000)

#### @user MLOps, LLMOps 프로젝트 구축 시게 pyenv poetry를 사용하는 이유?

@assistant Pyenv와 Poetry를 사용하는 주된 이유:

1.  **파이썬 버전 관리** (Pyenv):
    -   프로젝트별로 다른 파이썬 버전 요구사항 대응
    -   멀티 환경에서의 호환성 보장

2.  **의존성 관리** (Poetry):
    -   정확한 패키지 버전 고정 (`poetry.lock`)
    -   재현 가능한 빌드 환경 구성
    -   패키지 배포 간소화

3.  **MLOps/LLMOps 특화 장점**:
    -   모델 학습/서빙 환경의 일관성 유지
    -   대규모 라이브러리(예: PyTorch, Transformers) 버전 충돌 방지
    -   협업 시 개발 환경 표준화 용이

간결한 워크플로우: `pyenv` 로 파이썬 버전 설정 → `poetry` 로 가상환경 및 패키지 관리

#### @user 위와 같은 목적에서 miniconda와 uv와 비교

@assistant

#### **Miniconda vs Pyenv+Poetry vs UV 비교**

##### **1. Miniconda (Conda 기반)**

✅ **장점**:

-   **과학/ML 패키지 최적화**: PyTorch, TensorFlow 등 대규모 라이브러리 설치 용이 (Conda 채널 지원)
-   **통합 환경 관리**: Python 버전 + 패키지 + 가상환경을 한 번에 관리 (conda env)
-   **비-Python 종속성 지원** (CUDA, R 등)

❌ **단점**:

-   **용량 크고 느림** (기본 패키지 많음)
-   **의존성 해결이 복잡** 할 때가 있음 (conda vs pip 충돌)
-   **lock 파일 관리 불편** (Poetry보다 재현성 ↓)

➡ **적합한 경우**:

-   ML 연구용 로컬 환경 (GPU 연동 등)
-   Python 외 종속성 필요한 경우

---

##### **2. Pyenv + Poetry**

✅ **장점**:

-   **경량 &amp; 빠름** (Miniconda 대비)
-   **의존성 관리 정교함** (poetry.lock으로 재현성 ↑)
-   **패키지 배포 간편** (pyproject.toml 통합)

❌ **단점**:

-   **ML 패키지 설치 시 pip에 의존** (Conda보다 느리거나 실패 가능성 ↑)
-   **비-Python 종속성 관리 불가**

➡ **적합한 경우**:

-   Python 순수 프로젝트
-   협업 시 환경 표준화 필요할 때

---

##### **3. UV (Rust 기간 고속 패키지 관리자)**

✅ **장점**:

-   **초고속 의존성 해결** (Poetry/Conda보다 10~100배 빠름)
-   **경량 &amp; 현대적** (Rust 기반)
-   **pip/conda 호환**

❌ **단점**:

-   **새로운 도구** → 생태계 아직 성장 중
-   **ML 특화 기능 부재** (Conda 채널 미지원)

➡ **적합한 경우**:

-   빠른 빌드가 중요한 CI/CD 환경
-   대규모 프로젝트에서 의존성 해결 시간 단축 필요 시

---

#### @user pyenv 환경에서 poetry 설치 방법

@assistant

#### _Pyenv + Poetry 설치 가이드_

##### 1. Pyenv 설정

```shell
# Pyenv 설치 (이미 있으면 생략)
curl -fsSL https://pyenv.run | bash

# 필요한 빌드 도구 설치 (Ubuntu 예시)
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

# Python 설치 (예: 3.10.12)
pyenv install 3.10.12
```

##### 2. Poetry 설치

```shell
# 공식 설치 스크립트 사용 (권장)
curl -sSL https://install.python-poetry.org | python3 -

# PATH 설정 (~/.zshrc 또는 ~/.bashrc에 추가)
export PATH="HOME/.local/bin:PATH"
```

##### 3. 프로젝트 시작

```shell
# Python 버전 지정
pyenv local 3.10.12

# 새 프로젝트 생성
poetry new my_project
cd my_project

# 가상환경 생성 및 활성화
poetry install
poetry shell

# 패키지 추가 (예: PyTorch)
poetry add torch@latest --group main
```

##### _주의사항_

-   `poetry.lock` 파일은 반드시 버전 관리 시스템(Git)에 포함시킬 것
-   `pyproject.toml` 에 Python 버전 제약 조건 명시 예: \#+begin_src toml [tool.poetry.dependencies] python = "^3.10"

#### @user poetry 특정 버전을 설치하도록 명시 하는 방법

@assistant Poetry의 특정 버전을 설치하는 방법은 다음과 같습니다:

1.  **공식 설치 스크립트 사용 시 버전 지정**:



```shell
# 특정 버전(예: 1.4.2) 설치
curl -sSL https://install.python-poetry.org | python3 - --version 1.4.2
```

1.  **pip를 이용한 설치** (대체 방법):



```shell
# pyenv 가상환경 활성화 후
pip install poetry==1.4.2
```

1.  **이미 설치된 경우 버전 변경**:



```shell
# 기존 버전 제거 후 재설치
poetry self uninstall
curl -sSL https://install.python-poetry.org | python3 - --version 1.4.2
```

1.  **버전 확인**:



```shell
poetry --version
# 예상 출력: Poetry (version 1.4.2)
```

**주의사항**:

-   프로젝트 호환성을 위해 `pyproject.toml` 에 명시된 Poetry 버전 제약 조건 확인
-   특정 버전이 필요한 경우 팀 전체에서 동일한 버전 사용 권장
-   최신 버전 대신 구버전 사용 시 알려진 보안 취약점 확인 필요

**버전 선택 가이드**:

-   일반적인 사용: 최신 안정판 (현재 2.1.3)
-   레거시 프로젝트: 프로젝트 요구사항에 맞는 버전
-   CI/CD 환경: 모든 멤버가 동일한 버전 사용

#### @user
