[Python] 파이썬 의존성 관리 툴(pipenv)

happypath·2022년 1월 11일
0

Python

목록 보기
5/6

(Mac OS 기준)
프로젝트를 진행하다가, 팀원이 도입한 poetry를 무의식적으로 사용하던 중, 문득 의문이 들었다.
"파이썬 의존성관리툴에는 어떤게 있지? 알아봐야겠는데?"

그렇게 검색된 pipenv.

1. pipenv 사용하기

brew install pipenv
cd (원하는 폴더로 이동)
pipenv install

pipenv install 뒤에 버전을 직접 기입 혹은 --two, --three로 옵션을 주면 2, 3 버전에 맞춰 설치 된다.
(뒤에 별다른 옵션이 없을 경우에는 시스템 python 버전에 맞춰 설치 됨!)

**** 예시 ****
Use Python 3/2 when creating virtualenv.
--three / --two      


Create a new project using Python 3.7, specifically:
$ pipenv --python 3.7

Q: Pipfile과 Pipfile.lock 생성된 모습! 두 가지 차이가 뭐지?
A: "Pipfile is for people and Pipfile.lock is for computers."
pipenv lock is used to create a Pipfile. lock , which declares all dependencies (and sub-dependencies) of your project, their latest available versions, and the current hashes for the downloaded files.

pipfile.lock은 pipfile에 없는 더더더더 자세한 사항들을 담고 있고, 때문에 다른 개발자들과 의존성을 공유할 때는 lock파일을 공유해야함!

참고: Why does pipenv need Pipfile and Pipfile.lock?



  • 가상환경 실행하기
    pipenv shell
  • 패키지 설치 / 삭제
    pipenv install (패키지이름)
    pipenv uninstall (패키지이름)
  • 기존 requirements.txt에서 패키지 설치하기
    pipenv install -r requirements.txt
  • lock파일 업데이트(설치한 패키지들 업데이트)
    pipenv lock

0개의 댓글