본문 바로가기
FrameWork/Django

Poetry

by mansoorrr 2024. 7. 11.

[Poetry?]

python 개발시 패키지의 의존성을 관리하는 라이브러리

 

[설치방법]

  • With the official installer에서 개인 로컬환경에 따라 설치
  • vsCode에서 cmd를 통해 설치하려면 Linux라고 생각하고 설치
  • 설치 완료후 poetry --version입력시 버젼 나타나면 설치 성공!
  • cmd 닫은 후 다시 열어서 poetry입력하면 사용할 수 있는 명령어가 나타남
 

Introduction | Documentation | Poetry - Python dependency management and packaging made easy

If you installed using the deprecated get-poetry.py script, you should remove the path it uses manually, e.g. rm -rf "${POETRY_HOME:-~/.poetry}" Also remove ~/.poetry/bin from your $PATH in your shell configuration, if it is present.

python-poetry.org

 

[가상환경 구축]

  • 가상환경: 가상환경마다 버젼을 달리하여 관리 가능
  • poetry를 사용하여 가상환경 구축할 경우 poetry라는 명령어 사용(아래 순서대로 실행)
    • poetry init: 대화형 콘솔 실행됨(초기화)
      • License: MIT / 문장들: no / 마지막 confirm: yes
      • pyproject.toml 파일이 생성되고 거기에 가상환경 정보가 등록됨
    • poetry add <패키지명>: 가상환경에 패키지 설치(pip install과 같은 기능)
      • poetry.lock 파일 생성됨: 코드나 가상환경이 필요로 하는 모든 패키지에 대한 정보 가지고 있음
    • poetry shell: 가상환경으로 입장
      • 패키지를 poetry가상환경 안에 설치했기 때문에 가상환경 밖에서 패키지에 관련된 명령어를 실행하면 command not found에러를 맞게 됨
      • 패키지에서 나오고 싶으면 exit 입력하면 됨

 

'FrameWork > Django' 카테고리의 다른 글

App Models  (0) 2024.07.12
Application  (0) 2024.07.11
Setup Super User & settings  (0) 2024.07.11
Setup Admin & Migration  (0) 2024.07.11
Set up  (0) 2024.07.11