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

FeaturepipPoetry 1.8Poetry 2.1
Built-inOXX
Automatic virtual environment managementXOO
Dependency lock filerequirements.txt (manual)poetry.lockpoetry.lock
Project initialization commandXpoetry init / poetry newpoetry init / poetry new
Python version managementXXO (experimental)
pyproject.toml supportXOO
Plugin systemXLimitedO

1. 패키지 관리자 개요

기능pipPoetry 1.8Poetry 2.1
기본 제공 여부OXX
가상환경 자동 관리XOO
의존성 고정(lock) 파일requirements.txt (수동)poetry.lockpoetry.lock
프로젝트 초기화 명령어Xpoetry init / poetry newpoetry init / poetry new
Python 버전 관리XXO (실험적 기능)
pyproject.toml 지원XOO
플러그인 시스템X제한적O

2. Key Feature Comparison

2.1 Virtual Environment Management

  • pip: Requires manual creation of virtual environment with python -m venv env and 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.toml and poetry.lock.

2.2 의존성 관리

  • pip: requirements.txt를 수동으로 관리.
  • Poetry: pyproject.tomlpoetry.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

TaskpipPoetry 1.8Poetry 2.1
Package installationpip install package_namepoetry add package_namepoetry add package_name
Development package installationpip install package_namepoetry add --dev package_namepoetry add --dev package_name
Package removalpip uninstall package_namepoetry remove package_namepoetry remove package_name
Dependency installationpip install -r requirements.txtpoetry installpoetry install
Virtual environment activationsource venv/bin/activate (Linux/macOS)
venv\Scripts\activate (Windows)
poetry shellpoetry shell
Virtual environment deactivationdeactivateexit or deactivateexit or deactivate
Project initializationManual folder creation and venv setuppoetry init or poetry newpoetry init or poetry new
Python version specificationManual managementManual managementpoetry env use python_version (experimental)

3. 주요 명령어 비교

작업pipPoetry 1.8Poetry 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 new
Python 버전 지정수동 관리수동 관리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

Related Pages

© 2024 Coding Stairs. All rights reserved.