๐Ÿš€ Pipenv ๋กœ ํŒŒ์ด์ฌ ๊ฐ€์ƒํ™˜๊ฒฝ ์„ค์ •

DoonDoonยท2018๋…„ 12์›” 16์ผ
15
post-thumbnail

Photo by Chang Duong on Unsplash

โœ‹ ๋“ค์–ด๊ฐ€๊ธฐ ์ „์— (2019๋…„ 4์›” 28์ผ ์—…๋ฐ์ดํŠธ)


Pipenv ๋ฅผ ๊ฒ€์ƒ‰ํ•˜๋ฉด ๊ตฌ๊ธ€์—์„œ ๋ฌด๋ ค 3๋ฒˆ์งธ์— ๊ฒ€์ƒ‰๋˜๊ธฐ ๋•Œ๋ฌธ์— ํฐ ์ฑ…์ž„๊ฐ์„ ๊ฐ–๊ฒŒ ๋˜๋„ค์š” ใ… ใ… 
Pipenv ๋ฅผ ์‚ฌ์šฉํ•˜์‹œ๋Š” ๊ฒƒ์€ ์ž์œ ์ด์ง€๋งŒ ์ตœ๊ทผ ์—…๋ฐ์ดํŠธ๊ฐ€ ์ž‘๋…„ 11์›” 28์ผ ์ž…๋‹ˆ๋‹ค

์ตœ๊ทผ ๋“ค์–ด์„œ Pipenv ์‚ฌ์šฉ์„ ํ•˜์‹œ๋ ค๋Š” ๋ถ„๋“ค์„ ๋งŒ๋ฅ˜ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค

์™œ๋ƒ๋ฉด

  1. Officially Recommended ๋ผ๋Š” ๋ง์€ ํ—ˆ์ƒ์ž…๋‹ˆ๋‹ค.
    โ†’ https://chriswarrick.com/blog/2018/07/17/pipenv-promises-a-lot-delivers-very-little/
  2. ์—…๋ฐ์ดํŠธ๊ฐ€ ๋Š๋ฆฝ๋‹ˆ๋‹ค.
    โ†’ 6 ๊ฐœ์›” ๋„˜๊ฒŒ ๊ณต์‹ ๋ฆด๋ฆฌ์ฆˆ๊ฐ€ ์—†์œผ๋ฉด ๋ณดํ†ต์€ ๋‹ค์Œ ๋ฒ„์ „์— ๋Œ€ํ•œ ๋งˆ์ผ์Šคํ†ค์„ ์•Œ๋ ค์ค๋‹ˆ๋‹ค.
    โ†’ ์ผ๋ก€๋กœ NodeJS ์˜ yarn ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ €๋Š” ๋‹ค์Œ ์ผ์ •์— ๋Œ€ํ•œ ์ด์Šˆ ์“ฐ๋ ˆ๋“œ๊ฐ€ ์žˆ์–ด์š”
  3. ์‚ฌ์šฉ์ด ๋‹ค์†Œ ๋ถˆํŽธํ•˜๊ณ , ์‚ฌ์šฉ์ž๊ฐ€ ์•Œ์ง€ ๋ชปํ•˜๋Š” ๋ธ”๋ž™๋ฐ•์Šค ๋™์ž‘์ด ๋„ˆ๋ฌด ๋งŽ์Šต๋‹ˆ๋‹ค (locking, sync...)
    โ†’ ํŒจํ‚ค์ง€ ๋ช…์„ ์˜คํƒ€๋ƒˆ๋‹ค๊ฐ€ ๋‹ค์‹œ ์„ค์น˜ํ•˜๋ ค๋ฉด ์˜ค๋ฅ˜๋ฅผ ๋นผ์• ์•ก ๋‚ด๋ฑ‰๋Š”๋‹ค๊ฑฐ๋‚˜...

ํŒจํ‚ค์ง€ ์ด๋ฆ„ ์˜คํƒ€ ์˜ˆ์‹œ


pipenv install sqlalchem (์›๋ž˜๋Š” sqlalchemy ์ž…๋‹ˆ๋‹ค) ์ฒ˜๋Ÿผ
ํŒจํ‚ค์ง€ ์ด๋ฆ„์ด ์˜ค๋ฅ˜๊ฐ€ ๋‚˜๋ฉด ์ดํ›„์— pipenv install sqlalchemy ์ฒ˜๋Ÿผ ์ •์ƒ์ ์œผ๋กœ ์ž…๋ ฅํ•ด๋„

ERROR: ERROR: Could not find a version that matches sqlalchem
No versions found
Was https://pypi.org/simple reachable?

์ด๋Ÿฐ ์งœ์ฆ๋‚˜๋Š” ์˜ค๋ฅ˜๊ฐ€ ๋‚ฉ๋‹ˆ๋‹ค. ์™œ๋ƒ๋ฉด sqlalchem ์ด๋ผ๋Š” ํŒจํ‚ค์ง€๋ฅผ Pipfile ์— ์ด๋ฏธ ๊ธฐ๋กํ–ˆ๊ฑฐ๋“ ์š”
๊ทธ๋ž˜์„œ Pipfile ์—์„œ ์ € ํŒจํ‚ค์ง€๋ฅผ ์ง€์šฐ๊ณ  ๋‹ค์‹œ ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค

pyenv ๋กœ ๋Œ์•„๊ฐ€์‹œ๊ฑฐ๋‚˜, ๊ทธ๋ƒฅ Docker ๋ฅผ ์“ฐ์„ธ์š”.
์ €๋Š” ์š”์ฆ˜์€ ๊ทธ๋ƒฅ ๋„์ปค๋กœ ํ™˜๊ฒฝ์„ ๋งŒ๋“ค์–ด์„œ ์ฝ”๋”ฉํ•ฉ๋‹ˆ๋‹ค ใ…‡ใ……ใ…‡ ๋„ˆ๋ฌด ํŽธํ•ด์š”!
๊ทธ๋ž˜๋„ ๊ณ„์† ํ•˜์‹œ๋ ค๋ฉด ์ด์ œ ์ฝ์–ด ์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค

๐Ÿ‘‰ ๋“ค์–ด๊ฐ€๋Š” ๋ง


ํŒŒ์ด์ฌ ๊ฐ€์ƒํ™˜๊ฒฝ ์„ค์ •์— ๊ต‰์žฅํžˆ ์œ ์šฉํ•œ Pipenv ์„ค์น˜ ๋ฐ ์‚ฌ์šฉ๋ฒ•์— ๋Œ€ํ•œ ๊ฐ„๋‹จํ•œ ๊ฐ€์ด๋“œ ์ž…๋‹ˆ๋‹ค
๊ธฐ๋ณธ์ ์ธ ํŒŒ์ด์ฌ์— ๋Œ€ํ•œ ์ง€์‹๊ณผ, MacOS, Python3 ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค (์œˆ๋„์šฐ๋Š” ์ฃ„์†ก ๐Ÿ˜ž)

๐Ÿ“š Contents


  1. Pipenv?
  2. Installation
  3. ์‚ฌ์šฉ๋ฒ•
  4. ์ •๋ฆฌ

๐Ÿš€ Pipenv?


ํŒŒ์ด์จ๋‹ˆ์Šคํƒ€์ธ ์šฐ๋ฆฌ๋“ค์—๊ฒŒ ๋ช‡ ๊ฐ€์ง€ ์ด๋ฏธ ์œ ๋ช…ํ•œ ํŒจํ‚ค์ง€๋“ค์ด ์žˆ์Šต๋‹ˆ๋‹ค
tensorflow, numpy, pandas, django, flask... ์ด๋ ‡๊ฒŒ ํ•œ ๋ฒˆ ์ฏค ๋“ค์–ด๋ดค์„๋ฒ• ํ•œ ํŒจํ‚ค์ง€ ์ค‘์—
requests ๋ผ๋Š” HTTP client ํŒจํ‚ค์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค!

๊ทธ๋ฆฌ๊ณ  Pipenv ๋Š” requests ๋ฅผ ๋งŒ๋“  kennethreitz (์ผ€๋„ค์Šค ๋ ˆ์ด์ธ ) ๋ผ๋Š” ์‚ฌ๋žŒ์ด ๋งŒ๋“ 
ํŒŒ์ด์ฌ ์ „์šฉ ๊ฐ€์ƒํ™˜๊ฒฝ ์„ค์ • ํŒจํ‚ค์ง€ ์ž…๋‹ˆ๋‹ค!

(The Hitchhikerโ€™s Guide to Python! ๋ผ๋Š” ์ฑ…์˜ ์ €์ž์ด๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค! ์ž์„ธํ•œ๊ฑด ๋ธ”๋กœ๊ทธ!)

๐Ÿค” ๊ฐ€์ƒํ™˜๊ฒฝ?


๋Œ€๋ถ€๋ถ„์˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ๋งˆ์ฐฌ๊ฐ€์ง€์ด์ง€๋งŒ, ์ž‘์—…ํ•˜๋Š” ํ™˜๊ฒฝ์€ ๋Œ€๋‹จํžˆ ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค
๊ฐ™์€ ํŒŒ์ด์ฌ3 ๋ผ๊ณ  ํ• ์ง€๋ผ๋„ ๋ฒ„์ „์— ๋”ฐ๋ผ ์ง€์›์ด ๋˜๋Š” ํŒจํ‚ค์ง€๋“ค ๋˜ํ•œ ๋‹ค๋ฅด๊ณ 
๋ฌธ๋ฒ•๋„ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค

๋‹ค๋ฅธ์‚ฌ๋žŒ๊ณผ ํ˜‘์—…ํ•  ๋•Œ, ์„œ๋กœ ๊ฐ™์€ ํŒŒ์ด์ฌ ํ™˜๊ฒฝ์—์„œ ์ž‘์—…ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ๊ฐ€์ƒํ™˜๊ฒฝ์„ ๊ณ ๋ คํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค
ํŒŒ์ด์ฌ์˜ ๊ฐ€์ƒํ™˜๊ฒฝ์— ๋Œ€ํ•œ ๊ณต์‹ ๋ฌธ์„œ์˜ ์„ค๋ช…์€ ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค

๊ฐ€์ƒ ํ™˜๊ฒฝ์€ ํŠน์ • ๋ฒ„์ „ ํŒŒ์ด์ฌ ์„ค์น˜์™€ ์—ฌ๋Ÿฌ ์ถ”๊ฐ€ ํŒจํ‚ค์ง€๋ฅผ ํฌํ•จํ•˜๋Š” ์™„๋น„๋œ ํด๋” ํŠธ๋ฆฌ์ž…๋‹ˆ๋‹ค.
์ถœ์ฒ˜: https://docs.python.org/ko/3/tutorial/venv.html

ํŒŒ์ด์ฌ์˜ ๊ฐ€์ƒํ™˜๊ฒฝ์€ ๋˜ ํ•˜๋‚˜์˜ ํŒŒ์ด์ฌ์„ ์„ค์น˜ํ•˜๋Š” ๊ฒƒ๊ณผ ์œ ์‚ฌํ•ฉ๋‹ˆ๋‹ค

์ „์—ญ์œผ๋กœ ํŒŒ์ด์ฌ์„ ์„ค์น˜ํ•˜๋ฉด (homebrew ๋กœ ์„ค์น˜ํ–ˆ๋‹ค๋Š” ๊ฐ€์ •ํ•˜์—)

  • ํŒŒ์ด์ฌ ๋Ÿฐํƒ€์ž„
  • ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ง• ๊ด€๋ จ ์‹คํ–‰ํŒŒ์ผ(pip, wheel, setuptools)
  • ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ €์žฅ์†Œ(site-packages)

๋“ฑ์ด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค

๊ฐ€์ƒํ™˜๊ฒฝ์„ ์ด์šฉํ•˜๋ฉด, ์ด๋Ÿฌํ•œ ์„ค์ •์„ ๊ฒฉ๋ฆฌ๋œ ๊ณต๊ฐ„์— ๊ตฌ์„ฑ์‹œ์ผœ ์ค๋‹ˆ๋‹ค
๊ฐ€์ƒํ™˜๊ฒฝ์„ ์‹คํ–‰ํ•  ๊ฒฝ์šฐ (activate.sh) ์— ์ผ์–ด๋‚˜๋Š” ์ผ์— ๋Œ€ํ•ด์„œ๋Š” ์ด ๊ธ€ ์„ ์ฐธ๊ณ ํ•ด๋ณด์„ธ์š”

๋Œ€๋žต์ ์œผ๋กœ๋Š”

  • PYTHON_PATH ์™€ ๊ฐ™์€ ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ฅผ ๋ณ€๊ฒฝํ•˜๊ณ 
  • shell ์˜ subprocess ์ƒ์„ฑ
  • shell prompt ๋ณ€๊ฒฝ

๊ณผ ๊ฐ™์€ ์ž‘์—…์„ ํ•ฉ๋‹ˆ๋‹ค!

์š”์•ฝํ•˜๋ฉด,
๋‚ด ์ฝคํ”ผํƒ€์— ์ง€์ •๋œ ๋ฒ„์ „์˜ ํŒŒ์ด์ฌ์„ ํ•˜๋‚˜ ๋” ์„ค์น˜ํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ•˜์‹œ๋ฉด ๋  ๋“ฏ ํ•ฉ๋‹ˆ๋‹ค

๋งŒ์•ฝ OS ์ˆ˜์ค€์˜ ํ™˜๊ฒฝ๊นŒ์ง€ ๋™์ผํ•˜๊ฒŒ ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด, Docker ๋ฅผ ๊ณ ๋ คํ•ด๋ณด์„ธ์š”
์ด์— ๋Œ€ํ•œ ์„ค๋ช…์€ ํ›Œ๋ฅญํ•˜์‹  ๋ถ„๋“ค๊ผ์„œ ์ž˜ ์„ค๋ช…ํ•ด์ฃผ์…จ์œผ๋‹ˆ ์ฝ์–ด๋ณด์„ธ์š”!

  1. PyCharm + Docker๋กœ ํŒŒ์ด์ฌ ๊ฐœ๋ฐœํ™˜๊ฒฝ ์…‹์—…ํ•˜๊ธฐ (Dockerization)
  2. [Python] ๋„์ปค vs Vagrant vs virtualenv

๐Ÿ“ฆ Installation


๋‹น์—ฐํ•˜์ง€๋งŒ ์„ค์น˜๋ฅผ ํ•ด์•ผ ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ฌ๋ฐ”๋ฅธ ์„ค์น˜ ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋‘๋Š”๊ฑด ์—„์ฒญ ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค
์™œ๋ƒ๋ฉด ์ด์ƒํ•˜๊ฒŒ ์„ค์น˜๋˜๋ฉด ์—‰ํ‚จ ๊ฑธ ํ‘ธ๋Š”๊ฒŒ ์–ด๋ ค์›Œ์š”

์•„๋ž˜์™€ ๊ฐ™์€ ์ˆœ์„œ๋กœ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค

  1. python ๋ฒ„์ „๊ณผ, pip ๋ฒ„์ „ ์ฒดํฌ
  2. ์ „์—ญ์— pipenv ์„ค์น˜
  3. ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์„ค์น˜๋˜์—ˆ๋Š”์ง€ ํ™•์ธ

โœ… python ๋ฒ„์ „๊ณผ, pip ๋ฒ„์ „ ์ฒดํฌ


MacOS ์—๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ python2 ๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค (Mojave ๊ธฐ์ค€)

$ python --version
Python 2.7.15

$ python3 --version  # ๋งŒ์•ฝ ์„ค์น˜ํ•˜์ง€ ์•Š์œผ์…จ์œผ๋ฉด, ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ํŠน๋ณ„ํ•œ ์ด์œ ๊ฐ€ ์•„๋‹ˆ๋ผ๋ฉด Python3 ๋ฅผ ์‚ฌ์šฉํ•ด ์ฃผ์„ธ์š”
Python 3.7.1

๋งŒ์•ฝ Python3 ๋ฅผ ์„ค์น˜ ํ•˜์ง€ ์•Š์•˜๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์„ค์น˜ํ•ด์ฃผ์„ธ์š”

$ brew install python3  # ์˜์ƒ์€ ์ด๋ฏธ ์ €๋Š” ์„ค์น˜๋˜์–ด ์žˆ์–ด์„œ reinstall ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค

python3_homebrew_install.gif

pip ๋ฒ„์ „ ํ™•์ธ (pip ๋Š” NodeJS์˜ npm ๊ณผ ๋น„์Šทํ•œ ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค)

$ pip --version
pip 18.0 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)  # homebrew ๋กœ ์„ค์น˜ํ•œ ๊ฒฝ์šฐ

$ pip3 --version
pip 18.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)  # homebrew ๋กœ ์„ค์น˜ํ•œ ๊ฒฝ์šฐ

python3 ๋ฅผ ์˜ˆ์ „์— ์„ค์น˜ํ•˜์…จ๊ฑฐ๋‚˜
pip ์—…๊ทธ๋ ˆ์ด๋“œ๋ฅผ ํ•˜์‹ ์ง€ ์‹œ๊ฐ„์ด ์ง€๋‚ฌ๋‹ค๋ฉด ์—…๊ทธ๋ ˆ์ด๋“œ๋ฅผ ํ•˜๊ณ  ์ง„ํ–‰ํ•˜์‹œ๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•ฉ๋‹ˆ๋‹ค

$ brew reinstall python3
$ pip3 install pip --upgrade
$ pip3 --version
pip 18.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)  # ์—…๊ทธ๋ ˆ์ด๋“œ ์„ฑ๊ณต ๐Ÿ‘

๐ŸŒ ์ „์—ญ์— Pipenv ์„ค์น˜


์ œ๊ฐ€ ์œ„์—์„œ pip์™€ pip3์˜ ๋ฒ„์ „์„ ๊ฐ๊ฐ ์ฒดํฌํ–ˆ์„๋•Œ
๊ด„ํ˜ธ ์•ˆ์— (python 2.7) ๋˜๋Š” (python 3.7) ๋กœ ๋‚˜ํƒ€๋‚˜๋Š”๊ฑธ ๋ณด์…จ๋‚˜์š”?
pip๋Š” ๊ฐ๊ฐ์˜ ํŒŒ์ด์ฌ ๋Ÿฐํƒ€์ž„๊ณผ ์—ฐ๊ฒฐ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค

๊ทธ๋ž˜์„œ, StackOverflow ๊ฐ™์€ ๊ณณ์—์„œ ์ฝ”๋“œ๋ฅผ ๊ทธ๋Œ€๋กœ ๋ณต๋ถ™ํ•˜๋ฉด ์˜๋„์ง€ ์•Š์€ ๋™์ž‘์ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค
ํŠนํžˆ๋‚˜ sudo pip install ๊ฐœ์ฉŒ๋Š”ํŒจํ‚ค์ง€ ๋˜๋Š” pip install ์งฑ์ข‹์€ํŒจํ‚ค์ง€ --user ์™€ ๊ฐ™์€ ์„ค์น˜ ๋ฐฉ๋ฒ•์€
๊ฐœ์ธ์ ์œผ๋กœ๋Š” ์‚ฌํƒ„๋„ ํ•œ ์ˆ˜ ์ ‘๊ณ  ๊ฐ€๋Š” ์กฐ์–ธ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค ๐Ÿ‘น

sudo ๋กœ ์„ค์น˜ํ•˜๋Š” ๊ฒฝ์šฐ๋Š” ์•„์‹œ๊ฒ ์ง€๋งŒ, ๊ถŒํ•œ์ด ๊ผฌ์—ฌ๋ฒ„๋ฆด ๋ฌธ์ œ๊ฐ€ ๋‹ค๋ถ„ํ•ฉ๋‹ˆ๋‹ค
์„ค์น˜๋Š” sudo๋กœ ํ–ˆ๋Š”๋ฐ, ํŒŒ์ด์ฌ ๋Ÿฐํƒ€์ž„์€ sudo ๊ถŒํ•œ์ด ์—†๋‹ค๋ฉด...? ํŒจํ‚ค์ง€ ์‹คํ–‰์ด ์•ˆ๋˜๊ฒ ์ฃ ?
sudo ์„ค์น˜์˜ ๋ฌธ์ œ์— ๋Œ€ํ•ด ์ž˜ ๋‹ค๋ค„์ฃผ์‹  ๊ธ€์˜ ์žˆ์–ด ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค โ†’ Sudo pip install์€ ์•ˆ๋ผ์š”!

๋‹ค์‹œ ๋ณธ๋ก ์œผ๋กœ ๋Œ์•„์™€์„œ,
pip ๋Š” python 2.7.15 ์˜ ๊ฒƒ์ž…๋‹ˆ๋‹ค. pip3 ๋Š” python 3.7.1 ์˜ ๊ฒƒ์ด๊ตฌ์š”

๋Œ€๋‹จํžˆ ์ค‘์š”ํ•œ ์ ์ž…๋‹ˆ๋‹ค. ๋งŒ์•ฝ ์ € ์‚ฌ์‹ค์„ ์ธ์ง€ํ•˜์ง€ ๋ชปํ•˜๊ณ 
pip install pipenv ๋ผ๊ณ  ํ•ด๋ฒ„๋ฆฌ๋ฉด
pipenv๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ python2๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์‹คํ–‰๋˜๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค

์ตœ์ดˆ์— ์ „์ œ๋ฅผ Python3 ํ™˜๊ฒฝ์ด๋ผ๊ณ  ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์—, ์šฐ๋ฆฌ๋Š” ์•„๋ž˜์™€ ๊ฐ™์€ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค

$ pip3 install pipenv
$ pipenv --version
pipenv, version 2018.11.26  # 181216 ๊ธฐ์ค€

์ด์ œ ์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๊ทผ๋ฐ ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ์ฝ์–ด๋ณด์‹  ๋ถ„๋“ค์€ homebrew ๋กœ ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์•ˆ๋‚ดํ•˜๋Š”๋ฐ
์™œ pip3 ๋กœ ์„ค์น˜ํ•˜๋Š”์ง€ ๊ถ๊ธˆํ•ด ํ•˜์‹œ๋Š” ๋ถ„๋“ค์ด ๋งŽ์„ ๊ฑฐ๋ผ๊ณ  ์ƒ๊ฐํ•ด์š”

์–ผ๋งˆ ์ „(์•„๋งˆ 9์›” ๊ฒฝ), Python3 ์˜ stable ์ด 3.6.5 ์—์„œ 3.7.1 ๋กœ ์˜ฌ๋ผ๊ฐ€๋ฉด์„œ
homebrew ์˜ python3 ๊ธฐ๋ณธ ๋ฒ„์ „๋„ 3.7 ๋ฒ„์ „์ด ๋˜์—ˆ์Šต๋‹ˆ๋‹ค
ํ•˜์ง€๋งŒ ๋งŽ์€ ํŒจํ‚ค์ง€๋“ค์ด ์•„์ง 3.7 ์„ ์ง€์›ํ•˜์ง€ ๋ชปํ•˜๊ณ  ์žˆ์—ˆ์ฃ  (Pipenv ๋„ ๋งˆ์ฐฌ๊ฐ€์ง€ ์ž…๋‹ˆ๋‹ค)
๊ทธ๋ž˜์„œ homebrew ์—์„œ Python3 ๋ฒ„์ „์„ ๊ฐ•์ œ๋กœ 3.6.5_1 ๋กœ ๋กค๋ฐฑํ•˜๊ณ 
๋‹ค์‹œ Pipenv ๋ฅผ ์„ค์น˜ํ•ด์•ผ ํ•˜๋Š” ๋ถˆ์ƒ์‚ฌ๊ฐ€ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค...

์ง€๊ธˆ์€ ๊ดœ์ฐฎ์ง€๋งŒ ์–ธ์ œ ์ด๋Ÿฐ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ• ์ง€ ๋ชจ๋ฅด๊ธฐ ๋•Œ๋ฌธ์—
pip3 ๋กœ ์„ค์น˜ํ•˜๋Š” ๊ฒƒ์„ ์„ ํ˜ธํ•˜๋Š” ํŽธ์ž…๋‹ˆ๋‹ค

๐Ÿ‘€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์„ค์น˜๋˜์—ˆ๋Š”์ง€ ํ™•์ธ


์ผ๋‹จ pip3 ๋กœ ์ž˜ ์„ค์น˜๋˜์—ˆ๋Š”์ง€,
Pipenv ์˜ ํŒŒ์ด์ฌ ๋Ÿฐํƒ€์ž„์ด 3.7.1 ์ธ์ง€ ํ™•์ธํ•˜๋ฉด ๋˜๊ฒ ์Šต๋‹ˆ๋‹ค

$ pip3 freeze  # ๋งŒ์•ฝ ๋‹ค๋ฅธ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜์…จ์œผ๋ฉด, ๋” ๋‚˜ํƒ€๋‚˜๊ฒ ์ฃ 
certifi==2018.11.29
pipenv==2018.11.26  # ์–˜๋ž‘
virtualenv==16.1.0  # Pipenv์˜ ์˜์กด์„ฑ์ธ ์–˜๋ž‘
virtualenv-clone==0.4.0 # ์• ๋„...

$ cd $HOME  # ์ง‘์œผ๋กœ...
$ mkdir pipenv-test && cd pipenv-test  # ํ…Œ์ŠคํŠธํ•ด๋ณผ ํด๋”๋ฅผ ํ•˜๋‚˜ ๋งŒ๋“ค์–ด์š”
$ pipenv shell  # ์ด๋”ฐ ์„ค๋ช…ํ•˜๊ฒ ์ง€๋งŒ, ๊ฐ€์ƒํ™˜๊ฒฝ ์‹œ์ž‘ ๋ช…๋ น์–ด ์ž…๋‹ˆ๋‹ค
(pipenv-test-tXHIoQb5) $ python --version  # ์ด์ œ ๋” ์ด์ƒ python3 --version ์ด ์•„๋‹Œ์ ๋„ ์ฐธ๊ณ ํ•˜์„ธ์š”
(pipenv-test-tXHIoQb5) $ pipenv --rm  # ํ™•์ธํ–ˆ์œผ๋‹ˆ ์ง€์›์‹œ๋‹ค
(pipenv-test-tXHIoQb5) $ exit  # ์ด ์‰˜์—์„œ ๋‚˜๊ฐ€์„œ
$ cd .. && rm -rf pipenv-test  # ์—„๋งˆ๊ฐ€ ๋ฌผ๊ฑด ์ผ์œผ๋ฉด ์ œ ์ž๋ฆฌ์— ๋‘๋ผ๊ณ ...

๐Ÿ‘จโ€๐Ÿซ ์‚ฌ์šฉ๋ฒ•


์„ค์น˜๋Š” ์ž˜ ํ–ˆ์Šต๋‹ˆ๋‹ค. ์‹œ์ž‘์ด ๋ฐ˜ ์ธ๋ฐ ์‹œ์ž‘๋„ ํ–ˆ๊ณ  ์„ค์น˜๋„ ํ–ˆ์œผ๋‹ˆ ์‚ฌ์‹ค์ƒ ๋‹ค ํ–ˆ์Šต๋‹ˆ๋‹ค
์ด์ œ ์ง„์งœ ์จ๋ด์•ผ๊ฒ ์ฃ 

์ผ๋‹จ ๋ชจ๋ฅด๋ฉด man-page ๋ฅผ ๋ณด๋Š”๊ฒŒ ์ธ์ง€์ƒ์ •

$ pipenv --help

Usage: pipenv [OPTIONS] COMMAND [ARGS]...

Options:
  --where             Output project home information.
  --venv              Output virtualenv information.
  --py                Output Python interpreter information.
  --envs              Output Environment Variable options.
  --rm                Remove the virtualenv.
  --bare              Minimal output.
  --completion        Output completion (to be eval'd).
  --man               Display manpage.
  --support           Output diagnostic information for use in GitHub
                      issues.
  --site-packages     Enable site-packages for the virtualenv.  [env var:
                      PIPENV_SITE_PACKAGES]
  --python TEXT       Specify which version of Python virtualenv should
                      use.
  --three / --two     Use Python 3/2 when creating virtualenv.
  --clear             Clears caches (pipenv, pip, and pip-tools).  [env
                      var: PIPENV_CLEAR]
  -v, --verbose       Verbose mode.
  --pypi-mirror TEXT  Specify a PyPI mirror.
  --version           Show the version and exit.
  -h, --help          Show this message and exit.


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

   Remove project virtualenv (inferred from current directory):
   $ pipenv --rm

   Install all dependencies for a project (including dev):
   $ pipenv install --dev

   Create a lockfile containing pre-releases:
   $ pipenv lock --pre

   Show a graph of your installed dependencies:
   $ pipenv graph

   Check your installed dependencies for security vulnerabilities:
   $ pipenv check

   Install a local setup.py into your virtual environment/Pipfile:
   $ pipenv install -e .

   Use a lower-level pip command:
   $ pipenv run pip freeze

Commands:
  check      Checks for security vulnerabilities and against PEP 508
             markers provided in Pipfile.
  clean      Uninstalls all packages not specified in Pipfile.lock.
  graph      Displays currently-installed dependency graph information.
  install    Installs provided packages and adds them to Pipfile, or (if
             no packages are given), installs all packages from Pipfile.
  lock       Generates Pipfile.lock.
  open       View a given module in your editor.
  run        Spawns a command installed into the virtualenv.
  shell      Spawns a shell within the virtualenv.
  sync       Installs all packages specified in Pipfile.lock.
  uninstall  Un-installs a provided package and removes it from Pipfile.
  update     Runs lock, then sync.

๊ธฐ๋Šฅ์ด ๋งŽ์€๋ฐ, Commands ๋Š” ๋ช‡ ๊ฐœ ์•ˆ๋ฉ๋‹ˆ๋‹ค
ํŒจํ‚ค์ง€ ๊ด€๋ จ๋œ ๋ช…๋ น์–ด๋Š” check, clean, graph, install, lock, sync, uninstall, update
์‹คํ–‰๊ณผ ๊ด€๋ จ๋œ ๋ช…๋ น์–ด๋Š” open, run, shell ์ •๋„์ž…๋‹ˆ๋‹ค

์•„๋ž˜์™€ ๊ฐ™์€ ์ˆœ์„œ๋กœ ์‹ค์Šต ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค

  1. ๊ฐ€์ƒํ™˜๊ฒฝ ์ƒ์„ฑ
  2. ๊ฐ€์ƒํ™˜๊ฒฝ ์ž ๊น ์—ฟ๋ณด๊ธฐ
  3. ๊ฐ€์ƒํ™˜๊ฒฝ์—์„œ ํŒจํ‚ค์ง€ ์„ค์น˜ํ•˜๊ธฐ
  4. ๊ฐ€์ƒํ™˜๊ฒฝ์—์„œ ์Šคํฌ๋ฆฝํŠธ ์‹คํ–‰
  5. Pipfile, Pipfile.lock
  6. ๊ฐ€์ƒํ™˜๊ฒฝ ์ œ๊ฑฐ

๊ฐ€์ƒํ™˜๊ฒฝ ์ƒ์„ฑ


๋จผ์ € ๊ฐ€์ƒํ™˜๊ฒฝ์„ ์ฒ˜์Œ ์ƒ์„ฑํ•˜๋ ค๋ฉด ์œ„์— ๋‚˜์˜จ ๋ฐฉ๋ฒ•์ฒ˜๋Ÿผ
pipenv --python 3.7 ๊ณผ ๊ฐ™์ด ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค
๋˜๋Š” pipenv shell ๋กœ๋„ ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค

pipenv --python 3.7 ๊ณผ pipenv shell ๋ช…๋ น์–ด์˜ ์ฐจ์ด์ ์€
pipenv --python ... ๋ช…๋ น์–ด๋Š” ๊ฐ€์ƒํ™˜๊ฒฝ์„ ๋งŒ๋“ค๊ณ  ๋‚˜์„œ
๋”ฐ๋กœ pipenv shell ๋ช…๋ น์–ด๋กœ ๊ฐ€์ƒํ™˜๊ฒฝ์— ์ง„์ž…ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค

์—„๋ฐ€ํžˆ ๋งํ•ด์„œ, pipenv shell ๋ช…๋ น์–ด๋Š” ๊ฐ€์ƒํ™˜๊ฒฝ์„ ์‹œ์ž‘ํ•œ๋‹ค๋Š” ์˜๋ฏธ์ด๊ณ 
(๋งŒ์•ฝ ์—†๋‹ค๋ฉด ๊ฐ€์ƒํ™˜๊ฒฝ์„ ์ƒ์„ฑํ•˜๊ณ  ์‹œ์ž‘)
pipenv --python 3,7 ์€ ์ˆœ์ˆ˜ํ•˜๊ฒŒ, ํ•ด๋‹น ๋ฒ„์ „์˜ ํŒŒ์ด์ฌ ๊ฐ€์ƒํ™˜๊ฒฝ์„ ๋งŒ๋“œ๋Š” ์—ญํ• ๋งŒ ํ•ฉ๋‹ˆ๋‹ค!

์ค‘์š”ํ•œ ๊ฑด ์‹œ์ž‘ํ•˜๋ ค๋Š” ํ”„๋กœ์ ํŠธ ๋””๋ ‰ํ„ฐ๋ฆฌ์— ์œ„์น˜ํ•œ ์ƒํƒœ๋กœ ๊ฐ€์ƒํ™˜๊ฒฝ์„ ์ƒ์„ฑํ•ด์•ผ ํ•œ๋‹ค๋Š” ์  ์ž…๋‹ˆ๋‹ค.
ํ˜„์žฌ ์œ„์น˜๋ฅผ ๊ธฐ์ค€์œผ๋กœ, ๊ฐ€์ƒํ™˜๊ฒฝ ์ด๋ฆ„์„ ๋งŒ๋“ค๊ธฐ ๋•Œ๋ฌธ์ด์ฃ 

์•„๊นŒ์ฒ˜๋Ÿผ ๋จผ์ € ์‹ค์Šตํ•  ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ํ•˜๋‚˜ ๋งŒ๋“ญ๋‹ˆ๋‹ค

$ cd $HOME
$ mkdir pipenv-tutorial && cd pipenv-tutorial
$ pipenv shell #  ๋˜๋Š” pipenv --python 3.7

์ด๋ ‡๊ฒŒ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ์•„๋ž˜์ฒ˜๋Ÿผ ์ง„ํ–‰๋ฉ๋‹ˆ๋‹ค

pipenv_shell.gif

๊ฐ€์ƒํ™˜๊ฒฝ์ด ๋งŒ๋“ค์–ด ์กŒ์Šต๋‹ˆ๋‹ค!

์ถ”๊ฐ€. ๋””๋ ‰ํ† ๋ฆฌ ์ด๋ฆ„ ๊ธฐ์ค€์œผ๋กœ ๊ฐ€์ƒํ™˜๊ฒฝ์„ ๋งŒ๋“ค์ง€๋งŒ
๋‹น์—ฐํ•˜๊ฒŒ๋„ ~/pipenv-tutorial ์—์„œ pipenv shell ์„ ์‹คํ–‰ํ•˜๋Š” ๊ฒฝ์šฐ์™€
~/Desktop/pipenv-tutorial ์—์„œ pipenv shell ์„ ์‹คํ–‰ํ•˜๋Š” ๊ฒฝ์šฐ๋Š”
๋‹ค๋ฅธ ๊ฐ€์ƒํ™˜๊ฒฝ์„ ๋งŒ๋“ค๊ฒŒ ๋ฉ๋‹ˆ๋‹ค
(pipenv-tutorial ๊นŒ์ง€๋Š” ๊ฐ™์ง€๋งŒ ๋’ค์˜ -t1c6CZgR ๊ณผ ๊ฐ™์€ ์ž„์˜๋ฌธ์ž๊ฐ€ ๋‹ค๋ฆ…๋‹ˆ๋‹ค

๊ฐ€์ƒํ™˜๊ฒฝ ์ž ๊น ์—ฟ๋ณด๊ธฐ


๊ฐ€์ƒํ™˜๊ฒฝ์€ ํŒŒ์ด์ฌ์„ ํ•˜๋‚˜ ๋” ์„ค์น˜ํ•˜๋Š”๊ฑฐ๋ž‘ ๋น„์Šทํ•˜๋‹ค๊ณ  ๋ง์”€๋“œ๋ ธ์ฃ ?
๊ทธ๋Ÿผ ์ด๊ฑด ๋Œ€์ฒด ์–ด๋”” ์„ค์น˜๋˜๋Š” ๊ฑธ๊นŒ์š”?

pipenv --py ๋ช…๋ น์–ด๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค

(pipenv-tutorial-S-kj1fAT) $ pipenv --py
$HOME/.local/share/virtualenvs/pipenv-tutorial-S-kj1fAT/bin/python

$HOME ์˜ ์ˆจ๊ฒจ์ง„ ๋””๋ ‰ํ† ๋ฆฌ์ธ .local ์•ˆ์— ๊นŠ์ˆ™ํžˆ ์ƒ์„ฑ๋˜๋„ค์š”!

๊ฐ€์ƒํ™˜๊ฒฝ์—์„œ ํŒจํ‚ค์ง€ ์„ค์น˜ํ•˜๊ธฐ


ํŒŒ์ด์ฌ์—์„œ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜๋Š” ๋ช…๋ น์–ด๋Š” pip install ์ž…๋‹ˆ๋‹ค
Pipenv ํ™˜๊ฒฝ์—์„œ๋Š” pipenv install ๋กœ ์„ค์น˜ํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค!

(pipenv-tutorial-S-kj1fAT) $ pipenv install requests
Installing requestsโ€ฆ
Adding requests to Pipfile's [packages] โ€ฆ
โœ” Installation Succeeded
Pipfile.lock (b0f7f1) out of date, updating to (7b9a03)โ€ฆ
Locking [dev-packages] dependenciesโ€ฆ
โœ” Success!
Locking [packages] dependenciesโ€ฆ
โœ” Success!
Updated Pipfile.lock (b0f7f1)!
Installing dependencies from Pipfile.lock (b0f7f1)โ€ฆ
๐Ÿ โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰ 5/5 โ€” 0

๋‹จ, ์—ฌ๊ธฐ์„œ ๊ธฐ์กด ํŒจํ‚ค์ง€ ์„ค์น˜ ๋ฐฉ์‹๊ณผ๋Š” ๋‹ค๋ฅธ ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค
๋ฐ”๋กœ npm ์ฒ˜๋Ÿผ devDependencies ๋ฅผ ์ง€์›ํ•œ๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค
pipenv install --dev requests ๊ณผ ๊ฐ™์ด ์„ค์น˜ํ•  ๊ฒฝ์šฐ
Pipfile ์— [dev-packages] ํ•˜์œ„์— ๋ฆฌ์ŠคํŒ… ๋ฉ๋‹ˆ๋‹ค

$ cat Pipfile
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
requests = "*"  # ์—ฌ๊ธฐ์—

[packages]
requests = "*"

[requires]
python_version = "3.7"

๊ฐ€์ƒํ™˜๊ฒฝ์—์„œ ์Šคํฌ๋ฆฝํŠธ ์‹คํ–‰


๊ฐ„๋‹จํ•˜๊ฒŒ, ํ˜„์žฌ ํŒŒ์ด์ฌ ๋ฒ„์ „์„ ์ถœ๋ ฅํ•˜๋Š” app.py ๋ผ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค
ํ˜„์žฌ ๊ฒฝ๋กœ์— app.py ํŒŒ์ผ์„ ์•„๋ž˜์ฒ˜๋Ÿผ ๋งŒ๋“ค์–ด ์ฃผ์„ธ์š”

# ๐Ÿ“ app.py
import sys

def main():
    print(sys.version)

if __name__ == '__main__':
	main()

๊ทธ๋ฆฌ๊ณ  ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค

(pipenv-tutorial-S-kj1fAT) $ python app.py
3.7.1 (default, Nov 28 2018, 11:51:47)
[Clang 10.0.0 (clang-1000.11.45.5)]

๊ฐ€์ƒํ™˜๊ฒฝ ์•ˆ์—์„œ ์ž˜ ์‹คํ–‰๋˜๋„ค์š”!

๊ทผ๋ฐ, npm ์ฒ˜๋Ÿผ npm run ๊ฐ™์€ ๊ธฐ๋Šฅ์€ ์—†์„๊นŒ์š”? ๋ผ๊ณ  ๋ฌป๊ธฐ๊ฐ€ ๋ฏผ๋งํ•˜๋„ค์š”
๋‹น์—ฐํžˆ ์žˆ์Šต๋‹ˆ๋‹ค pipenv run [COMMAND] ๋กœ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค

๋จผ์ € Pipfile ์— [scripts] ์„น์…˜์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค

(pipenv-tutorial-S-kj1fAT) $ vi Pipfile

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
requests = "*"

[packages]
requests = "*"

[requires]
python_version = "3.7"

[scripts]  # ์„น์…˜์„ ๋งŒ๋“ค๊ณ 
start = "python app.py"  # ์‹คํ–‰ํ•  ์ปค๋งจ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜์„ธ์š”, "" ๋กœ ๊ฐ์‹ธ์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค

์œ„์™€ ๊ฐ™์ด start ๋ผ๋Š” ์ปค๋งจ๋“œ๋ฅผ ์ถ”๊ฐ€ํ–ˆ์œผ๋ฉด ์ด๋ ‡๊ฒŒ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค

(pipenv-tutorial-S-kj1fAT) $ pipenv run start
3.7.1 (default, Nov 28 2018, 11:51:47)
[Clang 10.0.0 (clang-1000.11.45.5)]

Pipfile, Pipfile.lock


pipenv shell ๋ช…๋ น์–ด๋ฅผ ์ƒ์„ฑํ•˜๋ฉด, ์ด ๋‘ ๊ฐ€์ง€ ํŒŒ์ผ์ด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค
์ด ํŒŒ์ผ๋“ค์€ ์–ด๋–ค ์—ญํ• ์„ ํ• ๊นŒ์š”?

์‰ฝ๊ฒŒ ์„ค๋ช…ํ•˜์ž๋ฉด, npm ์˜ package.json , package-lock.json ์— ๊ฐ๊ฐ ๋Œ€์‘๋ฉ๋‹ˆ๋‹ค
Pipfile ์€ Pipenv ๊ฐ€์ƒํ™˜๊ฒฝ์ด ์ฐธ๊ณ ํ•ด์•ผํ•  ์„ค์ •์ž…๋‹ˆ๋‹ค
(๊ฐ€์ƒํ™˜๊ฒฝ์˜ ํŒŒ์ด์ฌ ๋ฒ„์ „, ์„ค์น˜ํ•ด์•ผํ•  ํŒจํ‚ค์ง€, ์Šคํฌ๋ฆฝํŠธ ๋“ฑ)
Pipfile.lock ์€ deterministic-builds(๊ฒฐ์ •๋ก ์  ๋นŒ๋“œ) ๋ฅผ ๊ตฌํ˜„ํ•˜๋Š”๋ฐ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค

โš ๏ธ ๊ฒฐ์ •๋ก ์  ๋นŒ๋“œ๋ž€?
Be able to get the exact same set of dependencies on multiple machines.
โ†’ ์–ด๋–ค ์ƒํ™ฉ์—์„œ๋„ ๋™์ผํ•˜๊ฒŒ site-packages tree ๋ฅผ ์œ ์ง€ํ•˜๋ฉฐ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•จ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค
npm ํ™ˆํŽ˜์ด์ง€์˜ ๊ธ€์„ ์ฝ์–ด๋ณด์‹œ๋ฉด ์ข€ ๋” ์ž์„ธํžˆ ์ฐธ๊ณ ํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค

๊ฐ€์ƒํ™˜๊ฒฝ ์ œ๊ฑฐ


์‹ค์Šต์ด ๋๋‚ฌ์œผ๋‹ˆ ์ •๋ฆฌ๋ฅผ ํ•ด์•ผ๊ฒ ์–ด์š”
pipenv --rm ๋ช…๋ น์–ด๋กœ ๊ฐ€์ƒํ™˜๊ฒฝ์„ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค
๋‹จ, ์ƒ์„ฑ๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ, ์‚ญ์ œ์‹œ์—๋„ ํ”„๋กœ์ ํŠธ ํด๋”๋กœ ์ด๋™ํ•˜์—ฌ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค

(pipenv-tutorial-S-kj1fAT) $ pipenv --rm
Removing virtualenv (/Users/doondoony/.local/share/virtualenvs/pipenv-tutorial-t1c6CZgR) โ€ฆ

์ •๋ง ์ง€์›Œ์กŒ๋Š”์ง€ ์•„๊นŒ ์ž ๊น ์—ฟ๋ณด์•˜๋˜ ๊ฒฝ๋กœ ($HOME/.local/**/...) ์—์„œ ์ง์ ‘ ํ™•์ธํ•ด ๋ณผ๊นŒ์š”?

$ ls -al ~/.local/share/virtualenvs
... ์—†์Œ ... ๋˜๋Š” ๋”ฐ๋กœ ์ƒ์„ฑํ•˜์‹ ๊ฒŒ ์žˆ์œผ๋ฉด ๋ญ”๊ฐ€ ๋‚˜์˜ฌ์ง€๋„ ...

์ง์ ‘ ~/.local/share/virtualenvs ์—์„œ ๊ฐ€์ƒํ™˜๊ฒฝ ํด๋”๋ฅผ rm -rf ๋ช…๋ น์–ด๋กœ ์‚ญ์ œํ•ด๋„ ๋ฉ๋‹ˆ๋‹ค
์ง€์šฐ๋Š”๊ฒƒ๋„ ๊ฐ„๋‹จํ•˜๋„ค์š”!

๐Ÿงน ์ •๋ฆฌ


pipenv ๋Š” ๊ฐ„๋‹จํ•˜๊ฒŒ ๊ฐ€์ƒํ™˜๊ฒฝ์„ ์ƒ์„ฑํ•ด์ฃผ๊ณ 
๊ฒฐ์ •๋ก ์  ๋นŒ๋“œ๊ฐ€ ๊ฐ€๋Šฅํ•˜๋„๋ก ํ•˜์—ฌ ํ˜‘์—…์— ๊ต‰์žฅํžˆ ์ข‹์Šต๋‹ˆ๋‹ค

๋‹ค๋งŒ, ๊ฐœ์ธ์ ์ธ ์ƒ๊ฐ์œผ๋กœ๋Š” ์˜คํ”ˆ์†Œ์Šค์ด๋‹ค ๋ณด๋‹ˆ
Python3 ์˜ ๋ฒ„์ „, Pip ์˜ ๋ฒ„์ „ ์—…๊ทธ๋ ˆ์ด๋“œ์— ๋ฐ”๋กœ๋ฐ”๋กœ ๋Œ€์‘ํ•˜๊ธฐ๋Š” ์–ด๋ ค์šด ๋“ฏ ํ•ฉ๋‹ˆ๋‹ค

์ž ๊น ์•ผํฌํ„ธ์„ ๊นŽ์ž๋ฉด...
์ตœ๊ทผ pip18.1 ๋กœ ์—…๊ทธ๋ ˆ์ด๋“œ ๋˜๋ฉด์„œ, pipenv ์™€ ์ถฉ๋Œ์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค (ํ˜„์žฌ๋Š” ํ•ด๊ฒฐ)

์ด์— ๋Œ€ํ•œ ์ด์Šˆ ์“ฐ๋ ˆ๋“œ์ธ๋ฐ
"๊ฑด์„ค์ ์ด์ง€ ๋ชปํ•œ ๋ฉ”์‹œ์ง€๋ฅผ ํ”ผํ•˜๊ณ  ์ง์ ‘ ๋ฐœ์ „์— ๊ธฐ์—ฌํ•ด์ฃผ๋ฉด ์ข‹๊ฒ ์–ด.
์šฐ๋ฆฌ๋Š” ์–ธ์ œ๋‚˜ ์‚ฌ๋žŒ๋„ ๋ชจ์ž๋ฅด๊ธฐ ๋•Œ๋ฌธ์— ๊ธฐ๊บผ์ด ๋„ˆ์˜ ๋„์›€์„ ๋ฐ›์„ ์˜ํ–ฅ์ด ์žˆ์–ด"
์™€ ๊ฐ™์ด ์ด์•ผ๊ธฐํ•˜๋Š” ๊ฑธ๋กœ ๋ด์„œ, ์˜คํ”ˆ์†Œ์Šค๋ž€ ํž˜๋“ ๊ฑฐ๊ตฌ๋‚˜ ๋Š๋ผ๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค ๐Ÿค”

Pipfile, Pipfile.lock ํŒŒ์ผ์„ ํ†ตํ•ด, ๊ฐ„ํŽธํ•˜๊ฒŒ ํŒจํ‚ค์ง€ ๋ฐ ํŒŒ์ด์ฌ ๋ฒ„์ „ ๊ด€๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•˜๋ฉฐ
(pyenv, virtualenv, virtualenvwrapper ๋ชจ๋‘ ์‚ฌ์šฉํ•ด ๋ณด์•˜์—ˆ์Šต๋‹ˆ๋‹ค! ์ด๊ฒŒ ๊ฐ€์žฅ ํŽธํ•ด์š”)
python2 ์™€ python3 ๊ฐ€์ƒํ™˜๊ฒฝ์„ ๊ฐ๊ฐ ๋งŒ๋“œ๋Š”๊ฒŒ ์ •๋ง ์‰ฝ๋‹ค๋Š” ์  ๋˜ํ•œ ์—„์ฒญ๋‚œ ๋ฉ”๋ฆฌํŠธ ์ž…๋‹ˆ๋‹ค

์ด ์™ธ์—๋„ ๋” ๋งŽ์€ ๊ธฐ๋Šฅ์ด ์žˆ์œผ๋‹ˆ ์—ฌ๊ธฐ์—์„œ ์ฐธ๊ณ ํ•˜์„ธ์š”!

ํŽธ๋ฆฌํ•œ ๊ธฐ๋Šฅ๋“ค์ด๋ž€...

  1. ์ž๋™์œผ๋กœ .env ํŒŒ์ผ์ด ์žˆ์œผ๋ฉด ์ฝ์–ด์„œ ํ™˜๊ฒฝ๋ณ€์ˆ˜์— ๋“ฑ๋กํ•œ๋‹ค๊ฑฐ๋‚˜
  2. requirements.txt ํŒŒ์ผ์„ ํ†ตํ•ด ํŒจํ‚ค์ง€ ์„ค์น˜ ๊ฐ€๋Šฅ

๊ธด ๊ธ€ ์ฝ์–ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!

๐Ÿš€ TroubleShooting


๋งŒ์•ฝ Pipenv ์‹คํ–‰ ๊ณผ์ •์—์„œ ValueError: unknown locale: UTF-8 ์—๋Ÿฌ ๋ฉ”์‹œ์ง€๊ฐ€ ๋‚˜ํƒ€๋‚˜๋ฉด
์—ฌ๊ธฐ์—์„œ ์•ˆ๋‚ดํ•˜๋Š”๋Œ€๋กœ ์กฐ์น˜ํ•˜์„ธ์š”

profile
Espresso Cream Cat DD

12๊ฐœ์˜ ๋Œ“๊ธ€

comment-user-thumbnail
2018๋…„ 12์›” 16์ผ

์ข‹์€ ๊ธ€ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค~

1๊ฐœ์˜ ๋‹ต๊ธ€
comment-user-thumbnail
2018๋…„ 12์›” 17์ผ

ํ•ญ์ƒ ์ •์„ฑ๊ฐ€๋“ํ•œ ๊ธ€~!
์ € ์Šคํฌ๋กค ์–ด๋งˆ๋ฌด์‹œํ•œ ์Šค์ƒท์€ ์–ด๋–ป๊ฒŒ ์ฐ์œผ์‹ ๊ฑฐ์ฃ  ใ…‹ใ…‹

1๊ฐœ์˜ ๋‹ต๊ธ€
comment-user-thumbnail
2019๋…„ 2์›” 25์ผ

๊ธ€ ์ž˜ ์ฝ์—ˆ์Šต๋‹ˆ๋‹ค.

  1. Your Pipfile now contains pinned versions, if your requirements.txt did. We recommend updating your Pipfile to specify the "*" version, instead.

์ฒ˜๋Ÿผ, pipenv๊ฐ€ version specifier๋ฅผ "*"๋กœ ์„ค์ •ํ•˜๋„๋ก ํ•˜๋Š” ์ด์œ ๋Š” ๋ฌด์—‡์ธ๊ฐ€์š”?

  1. ๋‹จ์ˆœํžˆ ์ƒ๊ฐํ•˜๋ฉด pipenv shell๋กœ ๊ฐ€์ƒ ํ™˜๊ฒฝ์— ์ ‘์† ํ›„ python run ํ•˜๋Š” ๊ฑฐ๋‚˜ pipenv runํ•˜๋Š” ๊ฑฐ๋‚˜ ๊ฐ™์„ ๊ฒƒ ๊ฐ™์€๋ฐ, pipenv run ์ปค๋งจ๋“œ๊ฐ€ ๋”ฐ๋กœ ์ง€์›๋˜๋Š” ์ด์œ ๋Š” ๋ฌด์—‡์ธ๊ฐ€์š”?
1๊ฐœ์˜ ๋‹ต๊ธ€
comment-user-thumbnail
2019๋…„ 3์›” 4์ผ

์˜ค๋Š˜ pipenv์— ๊ด€๋ จํ•ด์„œ ์ž‘์—… ํ•˜๋‹ค๊ฐ€ ์™„๋ฃŒ๋˜๋‹ˆ ์ด ๊ธ€์ด ์ƒ๊ฐ๋‚˜์„œ.. pipenv install --system ์ปค๋งจ๋“œ๋Š” system python์— ์˜์กด์„ฑ์„ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค. pipenv๋กœ ๊ด€๋ฆฌ๋˜๊ณ  ์žˆ๋Š” ํ”„๋กœ์ ํŠธ๋ฅผ ECS์— ๋ฐฐํฌํ•˜๊ฑฐ๋‚˜ ํ•˜๋ฉด Dockerfile์— ์˜์กด์„ฑ์„ ์„ค์น˜ํ•˜๋Š” ์ปค๋งจ๋“œ๋ฅผ ๋„ฃ์–ด์•ผ ํ• ํ…๋ฐ, ๊ทธ๋ƒฅ pipenv install์€ venv๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ๊ฒƒ์ด ๋˜์–ด์„œ --system ์˜ต์…˜์ด ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐ์— ๋งค์šฐ ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”.

1๊ฐœ์˜ ๋‹ต๊ธ€
comment-user-thumbnail
2019๋…„ 3์›” 19์ผ

์ •๋ง ์ •์„ฑ์Šค๋Ÿฐ ๊ธ€์— ๋Œ“๊ธ€์„ ์•ˆ์“ธ๋ž˜์•ผ ์•ˆ์“ธ์ˆ˜๊ฐ€ ์—†๋„ค์š”
์ข‹์€ ๊ธ€ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

ํ˜น์‹œ ์ถ”๊ฐ€๋กœ, zsh ์„ค์ •ํ•œ ๊ฒƒ๋„ ๋‚˜์ค‘์— ์˜ฌ๋ ค์ฃผ์‹œ๋ฉด ์•ˆ๋ ๊นŒ์š”? ๋งค์šฐ ํƒ๋‚˜๋„ค์š”!

1๊ฐœ์˜ ๋‹ต๊ธ€
comment-user-thumbnail
2021๋…„ 4์›” 20์ผ

์ข‹์€ ๊ธ€ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!
์ฐจ๋ก€๋กœ ๋”ฐ๋ผํ•˜๋‹ค ์ตœ์ข…์ ์œผ๋กœ git.exc.InvalidGitRepositoryError ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋Š”๋ฐ ์•„๋ฌด๋ฆฌ ์ฐพ์•„๋ด๋„ ํ•ด๊ฒฐ๋ฐฉ๋ฒ•์„ ๋ชจ๋ฅด๊ฒ ์–ด์„œ ๋Œ“๊ธ€ ๋‚จ๊น๋‹ˆ๋‹ค ใ… ใ… 
ํ˜น์‹œ ๋ฌธ์ œ์˜ ๊ทผ์›๊ณผ ํ•ด๊ฒฐ๋ฐฉ๋ฒ•์„ ์•„์‹œ๋Š”์ง€์š”...ใ… 

1๊ฐœ์˜ ๋‹ต๊ธ€