๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Python/๊ฐ€์ƒํ™˜๊ฒฝ

[Python] ๊ฐ€์ƒํ™˜๊ฒฝ venv, pipenv ๋ช…๋ น์–ด ์ •๋ฆฌ

๋ฐ˜์‘ํ˜•

 

venv

python -m venv ๊ฐ€์ƒํ™˜๊ฒฝ์ด๋ฆ„

# ํ™˜๊ฒฝ๋ณ€์ˆ˜ path ์šฐ์„  ์ˆœ์œ„๊ฐ€ ๋†’์€ python ๋ฒ„์ „์œผ๋กœ ์ƒ์„ฑ
python -m venv venv

# path์™€ ์ƒ๊ด€์—†์ด ์„ค์น˜๋˜์–ด ์žˆ๋Š” ํŒŒ์ด์ฌ ์ค‘ ๋ฒ„์ „ ์ง€์ •ํ•˜์—ฌ ์ƒ์„ฑ
py -3.8 -m venv venv

# ํŒŒ์ด์ฌ์ด ์„ค์น˜๋œ ๊ฒฝ๋กœ ์ด์šฉํ•ด์„œ ์ƒ์„ฑ
D:\Programs\Python\Python310\python -m venv venv

 

์„ค์น˜๋˜์–ด์žˆ๋Š” ํŒŒ์ด์ฌ ๋ณด๊ธฐ : py -0

 

 

 

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

venv\Scripts\activate

 

๋น„ํ™œ์„ฑํ™”

deactivate

 

ํŒจํ‚ค์ง€ ์ด๋ฆ„๊ณผ ๋ฒ„์ „ ์ถœ๋ ฅ

pip list

 

 

pip ์ผ๊ด„ ์„ค์น˜

pip install -r requirements.txt

# ์‚ญ์ œ
pip uninstall -r requirements.txt

 

ํŒจํ‚ค์ง€ ๋ชฉ๋ก๊ณผ ๋ฒ„์ „ ์ •๋ณด๋ฅผ requirements.txt ํŒŒ์ผ์— ์ €์žฅํ•˜๋Š” ๋ช…๋ น์–ด

pip freeze > requirements.txt

 

vs code ๋””๋ฒ„๊น… ์˜ค๋ฅ˜ ๋‚  ๋•Œ

~~venv\Scripts\Activate.ps1 ํŒŒ์ผ์ด ๋””์ง€ํ„ธ ์„œ๋ช…๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.~~~~

 

Poweshell ๊ด€๋ฆฌ์ž ๋ชจ๋“œ๋กœ ์‹คํ–‰ ํ›„, ์•„๋ž˜ ์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰ํ•œ๋‹ค. powershell ๋ณด์•ˆ์ •์ฑ…์„ ๋„๋Š” ๊ฒƒ์ž„..

Set-ExecutionPolicy Unrestricted

 

 

 

https://bentist.tistory.com/53

 

ํŒŒ์ด์ฌ ์—ฌ๋Ÿฌ ๋ฒ„์ „์œผ๋กœ ๊ฐ€์ƒ ํ™˜๊ฒฝ ์„ค์น˜ํ•˜๊ธฐ(windows)

์–ด๋–ค ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ํŠน์ •ํ•œ ๋ฒ„์ „์˜ ํŒŒ์ด์ฌ์—์„œ๋งŒ ๋™์ž‘ํ•œ๋‹ค๋ฉด? ํ˜„์žฌ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” ํŒŒ์ด์ฌ ๋ฒ„์ „์ด ์•„๋‹Œ, ํŒŒ์ด์ฌ ํŠน์ • ๋ฒ„์ „์—์„œ๋งŒ ์‹คํ–‰๋˜๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์žˆ๋‹ค๋ฉด ๋‚œ๊ฐํ•ด์ง„๋‹ค. ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด

bentist.tistory.com

 

https://hleecaster.com/python-venv/

 

ํŒŒ์ด์ฌ ๊ฐ€์ƒํ™˜๊ฒฝ venv ์‚ฌ์šฉํ•˜๊ธฐ (ํŒจํ‚ค์ง€ ์‰ฝ๊ฒŒ ๊ด€๋ฆฌํ•˜๊ธฐ) - ์•„๋ฌดํŠผ ์›Œ๋ผ๋ฐธ

ํŒŒ์ด์ฌ์—์„œ venv๋ฅผ ํ™œ์šฉํ•œ ๊ฐ€์ƒํ™˜๊ฒฝ ์‚ฌ์šฉ๋ฒ•, ํด๋” ๊ด€๋ฆฌ, pip ํŒจํ‚ค์ง€ ๊ด€๋ฆฌ๋ฅผ ์ตœ๋Œ€ํ•œ ์‰ฝ๊ฒŒ ์ •๋ฆฌํ•ด๋ณด์•˜๋‹ค.

hleecaster.com

 

https://dojang.io/mod/page/view.php?id=2470 

 

ํŒŒ์ด์ฌ ์ฝ”๋”ฉ ๋„์žฅ: 47.11 ๊ฐ€์ƒํ™˜๊ฒฝ ์‚ฌ์šฉํ•˜๊ธฐ

ํŒŒ์ด์ฌ์„ ์‚ฌ์šฉํ•˜๋‹ค ๋ณด๋ฉด pip๋กœ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜๊ฒŒ ๋˜๋Š”๋ฐ ์ด ํŒจํ‚ค์ง€๋“ค์€ ํŒŒ์ด์ฌ ์„ค์น˜ ํด๋”(๋””๋ ‰ํ„ฐ๋ฆฌ)์˜ Lib/site-packages ์•ˆ์— ์ €์žฅ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ pip๋กœ ์„ค์น˜ํ•œ ํŒจํ‚ค์ง€๋Š” ๋ชจ๋“  ํŒŒ์ด์ฌ ์Šคํฌ๋ฆฝํŠธ์—์„œ

dojang.io

 

 

pipenv

* ํ”„๋กœ์ ํŠธ๊ฐ€ ํ•œ๊ธ€์ด๋ž‘ ๊ณต๋ฐฑ ์„ž์ธ ํด๋”์•ˆ์— ์žˆ์„ ๊ฒฝ์šฐ vscode์—์„œ ๊ฐ€์ƒํ™˜๊ฒฝ์ด ์ธ์‹์ด ์•ˆ๋์Œใ…  

# ์„ค์น˜
pip install pipenv
 
# ๊ฐ€์ƒํ™˜๊ฒฝ ์„ค์ • 
pipenv --python 3.9

# ์‚ญ์ œ
pipenv --rm

# ๊ฐ€์ƒํ™˜๊ฒฝ ๋ฒ„์ „ ํ™•์ธ
pipenv run python --version

 

 

๊ฐ€์ƒ ํ™˜๊ฒฝ, ํŒŒ์ด์ฌ ์ธํ„ฐํ”„๋ฆฌํ„ฐ ์œ„์น˜ ํ™•์ธ

$ pipenv --venv
$ pipenv --py

 

 

# ํŒŒ์ด์ฌ ์‹คํ–‰
pipenv run python

# Pipfile ํ•œ๋ฒˆ์— ์„ค์น˜
pipenv install

# ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜
pipenv install pywebview

# ๊ฐœ๋ฐœ์šฉ์œผ๋กœ ์„ค์น˜
pipenv install pywebview --dev

# ์„ค์น˜๋œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํ™•์ธ
pipenv graph

# ํŒŒ์ด์ฌ ์ฝ”๋“œ ์‹คํ–‰
pipenv run main.py

# ๊ฐ€์ƒํ™˜๊ฒฝ์œผ๋กœ ์ง„์ž…
pipenv shell

# ํŒŒ์ด์ฌ ์ธํ„ฐํ”„๋ฆฌํ„ฐ ํ™•์ธ
which python

# ๊ฐ€์ƒํ™˜๊ฒฝ ๋‚˜์˜ค๊ธฐ
exit

 

# pyinstaller ์‹คํ–‰
pipenv run pyinstaller main.py

 

 

 

 

 

 

 

 

์ฐธ๊ณ 

https://devbull.xyz/python-create-environment/

 

ํŒŒ์ด์ฌ ๊ฐ€์ƒํ™˜๊ฒฝ ๋น„๊ต(pipenv, venv, pyenv, conda)

๐Ÿ–๊ท€์ฐฎ์€๋ฐ ๊ทธ๋ƒฅ ๊น”๋ฉด ์•ˆ๋ผ์š”? ํŒŒ์ด์ฌ์€ ๊ฐ™์€ ์ธํ„ฐํ”„๋ฆฌํ„ฐ ๋ฒ„์ „์ด๋ผ๋ฉด ๊ฐ™์€ ํŒจํ‚ค์ง€๋ฅผ ๊ณต์œ ํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ํ”„๋กœ์ ํŠธ A์™€ B์—์„œ Python 3.9.4๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋‹ค๋ฉด, A์—์„œ ์„ค์น˜ํ•œ ํŒจํ‚ค์ง€๋ฅผ B์—์„œ๋„ ์‚ฌ์šฉ

devbull.xyz

 

https://technote.kr/375

 

Python - pipenv ์„ค์ • ๋ฐ ์‚ฌ์šฉ

๊ธฐ๋ณธ python ํ™˜๊ฒฝ๊ณผ ๋ณ„๋„๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ฐ€์ƒ ํ™˜๊ฒฝ ์ œ๊ณต ์›ํ•˜๋Š” python ๋ฒ„์ „์„ ์„ค์ •ํ•˜์—ฌ ์‚ฌ์šฉ ํ•ด๋‹น ๊ฐ€์ƒ ํ™˜๊ฒฝ๋งŒ์„ ์œ„ํ•œ python library ๋ฅผ ์„ค์น˜ Pipfile, Pipfile.lock (pip ์„ค์ • ํŒŒ์ผ) ์„ ๊ธฐ๋ฐ˜์œผ๋กœ python lib..

technote.kr

 

https://www.daleseo.com/python-pipenv/

 

pipenv๋กœ ํŒจํ‚ค์ง€ ๊ด€๋ฆฌํ•˜๊ธฐ

Engineering Blog by Dale Seo

www.daleseo.com

 

https://gamedevlife.tistory.com/entry/python3you-must-use-pipenv

 

`pipenv`๋Š” ์ •๋ง ์ข‹๋‹ค.

์ด๊ฑฐ ์ •๋ง ์ข‹์•„. ์•„์ฃผ ์ข‹์•„. Install ์ผ๋‹จ ์„ค์น˜๋ถ€ํ„ฐ ํ•˜๊ณ  ์‹œ์ž‘ํ•˜์ž. ์–ด์จŒ๋“  ๋‹น์‹ ์€ pipenv ๋ฅผ ์“ฐ๊ฒŒ ๋  ๊ฒƒ์ด๋‹ค. ์ด ๊ธ€์—์„œ๋Š” ๋ฏธ์•ˆํ•˜์ง€๋งŒ mac ๊ธฐ๋ฐ˜ ์ปดํ“จํ„ฐ์— ๋Œ€ํ•ด์„œ๋งŒ ๋‹ค๋ฃฐ ๊ฒƒ ์ด๋‹ค. ๐Ÿ™‡๐Ÿป‍โ™‚๏ธ brew ๊ฐ€

gamedevlife.tistory.com

 

 

https://xshine.tistory.com/338

 

[Windows10] pipenv ์„ค์ •

1. pipenv ์„ค์น˜ $ pip install pipenv Collecting pipenv Downloading pipenv-2021.11.23-py2.py3-none-any.whl (3.6 MB) |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 3.6 MB 6.4 MB/s R..

xshine.tistory.com

 

https://heytech.tistory.com/320

 

[Python] pipenv ๋“ฑ์žฅ๋ฐฐ๊ฒฝ, ์„ค์น˜, ํŒจํ‚ค์ง€ ๊ด€๋ฆฌ ๋ฐฉ๋ฒ•

๐Ÿ”ญ ํฌ์ŠคํŒ… ๊ฐœ์š” pipenv๋Š” ํŒŒ์ด์ฌ์—์„œ ๊ณต์‹์œผ๋กœ ๊ถŒ์žฅํ•˜๋Š” ํŒจํ‚ค์ง€ ๊ด€๋ฆฌ ํˆด๋กœ์จ ๋ฌด์—‡๋ณด๋‹ค ํŽธ๋ฆฌํ•˜๊ณ  ์•ˆ์ •์ ์œผ๋กœ ํŒจํ‚ค์ง€ ๊ด€๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ€์ƒํ™˜๊ฒฝ ์‚ฌ์šฉ ์‹œ ๊ฐ€์žฅ ์ถ”์ฒœํ•˜๋Š” ํˆด์ž…๋‹ˆ๋‹ค. ๋ณธ ํฌ์Šค

heytech.tistory.com

 

๋ฐ˜์‘ํ˜•