Skip to content

Instantly share code, notes, and snippets.

@iamjjanga-ouo
Last active May 19, 2022 14:50
Show Gist options
  • Save iamjjanga-ouo/25cde966a6b7c86eaa103e743be63c4b to your computer and use it in GitHub Desktop.
Save iamjjanga-ouo/25cde966a6b7c86eaa103e743be63c4b to your computer and use it in GitHub Desktop.
pipenv

pipenv?

  • 파이썬에서도 패키지를 프로젝트 단위로 관리할 수 있도록 도와주는 패키지 관리 도구
  • 기본적으로 pip기반으로 동작
  • 프로젝트별 격리된 가상환경(virtual environment)제공

install

# mac
$ brew install pipenv
# linux
$ pip install pipenv

make virtualenv && Execute python

$ mkdir my-project; cd my-project
$ pipenv --python 3.9
$ pipenv run python
Creating a virtualenv for this project...
Pipfile: /workspace/my-project/Pipfile
Using /usr/bin/python3.9 (3.9.12) to create virtualenv...
...
✔ Successfully created virtual environment! 
Creating a Pipfile for this project...

`Pipfile`이 생성됨
```sh
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]

[requires]
python_version = "3.9"

Usage VirtualEnv

$ pipenv shell

Remove virtualenv

$ pipenv --rm

install package

$ pipenv install requests
Installing requests…
Adding requests to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✔ Success!
Updated Pipfile.lock (444a6d)!
Installing dependencies from Pipfile.lock (444a6d)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 5/5 — 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

개발용 패키지 설치

$ pipenv install pytest --dev

모든 패키지 한번에 설치

Pipfile.lock에 있는 패키지 설치

$ pipenv install
$ pipenv install --dev

other Commands

가상환경 확인

$ pipenv --venv

파이썬 인터프리터 위치 확인

$ pipenv --py

패키지 트리 구조

$ pipenv graph
pytest==5.3.4
  - attrs [required: >=17.4.0, installed: 19.3.0]
  - importlib-metadata [required: >=0.12, installed: 1.4.0]
    - zipp [required: >=0.5, installed: 2.0.0]
      - more-itertools [required: Any, installed: 8.1.0]
  - more-itertools [required: >=4.0.0, installed: 8.1.0]
  - packaging [required: Any, installed: 20.0]
    - pyparsing [required: >=2.0.2, installed: 2.4.6]
    - six [required: Any, installed: 1.14.0]
  - pluggy [required: >=0.12,<1.0, installed: 0.13.1]
    - importlib-metadata [required: >=0.12, installed: 1.4.0]
      - zipp [required: >=0.5, installed: 2.0.0]
        - more-itertools [required: Any, installed: 8.1.0]
  - py [required: >=1.5.0, installed: 1.8.1]
  - wcwidth [required: Any, installed: 0.1.8]
requests==2.22.0
  - certifi [required: >=2017.4.17, installed: 2019.11.28]
  - chardet [required: >=3.0.2,<3.1.0, installed: 3.0.4]
  - idna [required: >=2.5,<2.9, installed: 2.8]
  - urllib3 [required: >=1.21.1,<1.26,!=1.25.1,!=1.25.0, installed: 1.25.8]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment