Python Package Managers: pip vs Poetry 1.8 vs Poetry 2.1
Comparison of Python Package Managers: pip, Poetry 1.8, Poetry 2.1
When managing Python projects, package and virtual environment management is crucial. This document compares the key features and differences between pip, Poetry 1.8, and Poetry 2.1, and explains how to use each tool with examples.
Python 프로젝트를 관리할 때, 패키지 및 가상환경 관리는 매우 중요합니다. 이 문서에서는 pip, Poetry 1.8, Poetry 2.1의 주요 기능과 차이점을 비교하고, 각 도구의 사용법을 예제와 함께 설명합니다.
1. Package Manager Overview
| Feature | pip | Poetry 1.8 | Poetry 2.1 |
|---|---|---|---|
| Built-in | O | X | X |
| Automatic virtual environment management | X | O | O |
| Dependency lock file | requirements.txt (manual) | poetry.lock | poetry.lock |
| Project initialization command | X | poetry init / poetry new | poetry init / poetry new |
| Python version management | X | X | O (experimental) |
| pyproject.toml support | X | O | O |
| Plugin system | X | Limited | O |
1. 패키지 관리자 개요
기능 pip Poetry 1.8 Poetry 2.1 기본 제공 여부 O X X 가상환경 자동 관리 X O O 의존성 고정(lock) 파일 requirements.txt (수동) poetry.lock poetry.lock 프로젝트 초기화 명령어 X poetry init/poetry newpoetry init/poetry newPython 버전 관리 X X O (실험적 기능) pyproject.toml 지원 X O O 플러그인 시스템 X 제한적 O
2. Key Feature Comparison
2.1 Virtual Environment Management
- pip: Requires manual creation of virtual environment with
python -m venv envand manual activation. - Poetry 1.8 & 2.1: Automatically creates and manages virtual environments within the project directory.
2.1 가상환경 관리
- pip:
python -m venv env로 가상환경 생성 후 수동으로 활성화 필요.- Poetry 1.8 & 2.1: 프로젝트 디렉토리 내에서 자동으로 가상환경 생성 및 관리.
2.2 Dependency Management
- pip: Manually manages
requirements.txt. - Poetry: Manages dependencies and version locking through
pyproject.tomlandpoetry.lock.
2.2 의존성 관리
- pip:
requirements.txt를 수동으로 관리.- Poetry:
pyproject.toml과poetry.lock을 통해 의존성 및 버전 고정 관리.
2.3 Python Version Management (Poetry 2.1)
Poetry 2.1 experimentally supports Python version installation and management.
2.3 Python 버전 관리 (Poetry 2.1)
Poetry 2.1에서는 실험적으로 Python 버전 설치 및 관리를 지원합니다.
poetry env use 3.10 3. Key Command Comparison
| Task | pip | Poetry 1.8 | Poetry 2.1 |
|---|---|---|---|
| Package installation | pip install package_name | poetry add package_name | poetry add package_name |
| Development package installation | pip install package_name | poetry add --dev package_name | poetry add --dev package_name |
| Package removal | pip uninstall package_name | poetry remove package_name | poetry remove package_name |
| Dependency installation | pip install -r requirements.txt | poetry install | poetry install |
| Virtual environment activation | source venv/bin/activate (Linux/macOS) venv\Scripts\activate (Windows) | poetry shell | poetry shell |
| Virtual environment deactivation | deactivate | exit or deactivate | exit or deactivate |
| Project initialization | Manual folder creation and venv setup | poetry init or poetry new | poetry init or poetry new |
| Python version specification | Manual management | Manual management | poetry env use python_version (experimental) |
3. 주요 명령어 비교
작업 pip Poetry 1.8 Poetry 2.1 패키지 설치 pip install 패키지명poetry add 패키지명poetry add 패키지명개발용 패키지 설치 pip install 패키지명poetry add --dev 패키지명poetry add --dev 패키지명패키지 제거 pip uninstall 패키지명poetry remove 패키지명poetry remove 패키지명의존성 설치 pip install -r requirements.txtpoetry installpoetry install가상환경 활성화 source venv/bin/activate(Linux/macOS)
venv\Scripts\activate(Windows)poetry shellpoetry shell가상환경 비활성화 deactivateexit또는deactivateexit또는deactivate프로젝트 초기화 수동 폴더 생성 및 venv 설정 poetry init또는poetry newpoetry init또는poetry newPython 버전 지정 수동 관리 수동 관리 poetry env use Python버전(실험적 기능)
4. Basic Poetry Usage Examples
1) Installing Poetry
1) Poetry 설치
pip install poetry
2) Creating a New Project
2) 새 프로젝트 생성
poetry new myproject
cd myproject Or initialize an existing folder:
또는 기존 폴더에 초기화:
poetry init 3) Adding Packages
3) 패키지 추가
poetry add requests 4) Adding Development Packages
4) 개발용 패키지 추가
poetry add --dev pytest 5) Activating Virtual Environment
5) 가상환경 활성화
poetry shell 6) Installing Dependencies
6) 의존성 설치
poetry install 7) Updating Packages
7) 패키지 업데이트
poetry update 5. Notes and Recommendations
- It’s recommended to add the .venv folder and virtual environment-related files to .gitignore.
- You may need to configure virtual environment settings separately in IDEs (PyCharm, VSCode).
- While Poetry 2.1 supports Python version management, it’s still an experimental feature and should be used with caution.
- Poetry creates project-specific virtual environments, preventing contamination of the system-wide Python environment.
5. 주의사항 및 권장사항
- .venv 폴더나 가상환경 관련 파일은 .gitignore에 추가하는 것이 좋습니다.
- IDE(Pycharm, VSCode)에서 별도로 가상환경 설정을 잡아야 할 수 있습니다.
- Poetry 2.1부터는 Python 버전 관리 기능도 지원하지만, 아직 완전한 기능은 아니므로 주의가 필요합니다.
- Poetry는 프로젝트별 가상환경을 생성하기 때문에 시스템 전역 Python 환경을 오염시키지 않습니다.
6. Next
- Flet