๐ฅ
[Python] ๊ฐ์ํ๊ฒฝ ๋ง๋ค๊ธฐ (virtualenv ์ค์น, ์์ฑ, ํ์ฑํ, ์ ๊ฑฐ) ๋ณธ๋ฌธ
linux
[Python] ๊ฐ์ํ๊ฒฝ ๋ง๋ค๊ธฐ (virtualenv ์ค์น, ์์ฑ, ํ์ฑํ, ์ ๊ฑฐ)
•8• 2023. 5. 16. 20:20virtualenv vs venv
- venv๋ ํ์ค ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ผ ์ค์น ๋ถํ์ํ์ง๋ง virtualenv๋ ์ธ๋ถ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ก ๋ณ๋ ์ค์น ํ์
- ์๋: virtualenv๊ฐ ๋ ๋น ๋ฆ
- ํ์ฅ์ฑ: virtualenv๊ฐ ๋ ์ข์
- virtualenv๋ python ๋ฒ์ ์ด ๋ค๋ฅธ ๊ฐ์ํ๊ฒฝ์ ๋ง๋ค ์ ์์ง๋ง venv๋ ๋ถ๊ฐ๋ฅ
- virtualenv๋ pip ์ ๊ทธ๋ ์ด๋ ๊ฐ๋ฅํ๋ venv๋ ๋ถ๊ฐ๋ฅ
→ virtualenv๊ฐ ๋ ์ข์๋ณด์ฌ์ virtualenv๋ฅผ ์ฌ์ฉํ๊ธฐ๋ก ํ๋ค.
1. virtualenv ์ค์น
[testuser@test-server-1 ~]$ python3 -m pip install --user -U virtualenv
Collecting virtualenv
Downloading https://files.pythonhosted.org/packages/18/a2/7931d40ecb02b5236a34ac53770f2f6931e3082b7a7dafe915d892d749d6/virtualenv-20.17.1-py3-none-any.whl (8.8MB)
100% |โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 8.9MB 117kB/s
Collecting importlib-metadata>=4.8.3; python_version < "3.8" (from virtualenv)
Downloading https://files.pythonhosted.org/packages/a0/a1/b153a0a4caf7a7e3f15c2cd56c7702e2cf3d89b1b359d1f1c5e59d68f4ce/importlib_metadata-4.8.3-py3-none-any.whl
Collecting filelock<4,>=3.4.1 (from virtualenv)
Downloading https://files.pythonhosted.org/packages/84/ce/8916d10ef537f3f3b046843255f9799504aa41862bfa87844b9bdc5361cd/filelock-3.4.1-py3-none-any.whl
Collecting distlib<1,>=0.3.6 (from virtualenv)
Downloading https://files.pythonhosted.org/packages/76/cb/6bbd2b10170ed991cf64e8c8b85e01f2fb38f95d1bc77617569e0b0b26ac/distlib-0.3.6-py2.py3-none-any.whl (468kB)
100% |โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 471kB 1.8MB/s
Collecting platformdirs<3,>=2.4 (from virtualenv)
Downloading https://files.pythonhosted.org/packages/b1/78/dcfd84d3aabd46a9c77260fb47ea5d244806e4daef83aa6fe5d83adb182c/platformdirs-2.4.0-py3-none-any.whl
Collecting importlib-resources>=5.4; python_version < "3.7" (from virtualenv)
Downloading https://files.pythonhosted.org/packages/24/1b/33e489669a94da3ef4562938cd306e8fa915e13939d7b8277cb5569cb405/importlib_resources-5.4.0-py3-none-any.whl
Collecting typing-extensions>=3.6.4; python_version < "3.8" (from importlib-metadata>=4.8.3; python_version < "3.8"->virtualenv)
Downloading https://files.pythonhosted.org/packages/45/6b/44f7f8f1e110027cf88956b59f2fad776cca7e1704396d043f89effd3a0e/typing_extensions-4.1.1-py3-none-any.whl
Collecting zipp>=0.5 (from importlib-metadata>=4.8.3; python_version < "3.8"->virtualenv)
Downloading https://files.pythonhosted.org/packages/bd/df/d4a4974a3e3957fd1c1fa3082366d7fff6e428ddb55f074bf64876f8e8ad/zipp-3.6.0-py3-none-any.whl
Installing collected packages: typing-extensions, zipp, importlib-metadata, filelock, distlib, platformdirs, importlib-resources, virtualenv
Successfully installed distlib-0.3.6 filelock-3.4.1 importlib-metadata-4.8.3 importlib-resources-5.4.0 platformdirs-2.4.0 typing-extensions-4.1.1 virtualenv-20.17.1 zipp-3.6.0
2. ๊ฐ์ํ๊ฒฝ ๋ง๋ค๊ธฐ
์์ฑํ๊ณ ์ ํ๋ ๊ฒฝ๋ก๋ก ์ด๋ ํ ์๋ ๋ช ๋ น์ด ์ํ
# python3 -m virtualenv "๊ฐ์ํ๊ฒฝ๋ช
"
[testuser@test-server-1 ~]$ python3 -m virtualenv testenv
created virtual environment CPython3.6.8.final.0-64 in 6112ms
creator CPython3Posix(dest=/home/testuser/testenv, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/testuser/.local/share/virtualenv)
added seed packages: pip==21.3.1, setuptools==59.6.0, wheel==0.37.1
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
์๋ฃ๋๋ฉด ํด๋น ๊ฒฝ๋ก์ "๊ฐ์ํ๊ฒฝ๋ช "์ผ๋ก ๋๋ ํ ๋ฆฌ๊ฐ ์๊ธด๋ค.
[testuser@test-server-1 ~]$ ll ./testenv/*
-rw-rw-r-- 1 testuser testuser 206 5์ 16 06:16 ./testenv/pyvenv.cfg
./testenv/bin:
ํฉ๊ณ 56
-rw-rw-r-- 1 testuser testuser 2145 5์ 16 06:16 activate
-rw-rw-r-- 1 testuser testuser 1437 5์ 16 06:16 activate.csh
-rw-rw-r-- 1 testuser testuser 3022 5์ 16 06:16 activate.fish
-rw-rw-r-- 1 testuser testuser 3333 5์ 16 06:16 activate.nu
-rw-rw-r-- 1 testuser testuser 1754 5์ 16 06:16 activate.ps1
-rw-rw-r-- 1 testuser testuser 1208 5์ 16 06:16 activate_this.py
-rwxrwxr-x 1 testuser testuser 242 5์ 16 06:16 pip
-rwxrwxr-x 1 testuser testuser 242 5์ 16 06:16 pip-3.6
-rwxrwxr-x 1 testuser testuser 242 5์ 16 06:16 pip3
-rwxrwxr-x 1 testuser testuser 242 5์ 16 06:16 pip3.6
lrwxrwxrwx 1 testuser testuser 16 5์ 16 06:16 python -> /usr/bin/python3
lrwxrwxrwx 1 testuser testuser 6 5์ 16 06:16 python3 -> python
lrwxrwxrwx 1 testuser testuser 6 5์ 16 06:16 python3.6 -> python
-rwxrwxr-x 1 testuser testuser 229 5์ 16 06:16 wheel
-rwxrwxr-x 1 testuser testuser 229 5์ 16 06:16 wheel-3.6
-rwxrwxr-x 1 testuser testuser 229 5์ 16 06:16 wheel3
-rwxrwxr-x 1 testuser testuser 229 5์ 16 06:16 wheel3.6
./testenv/lib:
ํฉ๊ณ 0
drwxrwxr-x 3 testuser testuser 27 5์ 16 06:16 python3.6
./testenv/lib64:
ํฉ๊ณ 0
drwxrwxr-x 3 testuser testuser 27 5์ 16 06:16 python3.6
3. ๊ฐ์ํ๊ฒฝ ํ์ฑํ/๋นํ์ฑํ
# ํ์ฑํ
[testuser@test-server-1 ~]$ source testenv/bin/activate
(testenv) [testuser@test-server-1 ~]$
# ๋นํ์ฑํ
(testenv) [testuser@test-server-1 ~]$ deactivate
[testuser@test-server-1 ~]$
4. ๊ฐ์ํ๊ฒฝ ์ญ์
์ญ์ ์์๋ ๋๋ ํ ๋ฆฌ๋ฅผ ์ญ์ ํด์ฃผ๋ฉด ๋๋ค.
[testuser@test-server-1 ~]$ rm -r testenv
'linux' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
ํ์ผ ์์ ์๊ฐ ์ด๋จ์ ํ์ธ (0) | 2023.10.12 |
---|---|
[CentOS] yum์ผ๋ก ์ค์นํ ํจํค์ง ์ค์น ๊ฒฝ๋ก ํ์ธํ๋ ๋ฐฉ๋ฒ (0) | 2023.08.28 |
[docker] ๊ฐ๋จํ ๋ช ๋ น์ด ์ ๋ฆฌ (0) | 2023.06.30 |
parquet-cli๋ฅผ ํตํด parquet ํ์ผ์ ์ฌ๋ฌ๊ฐ์ง ์ ๋ณด ํ์ธ (metadata, schema ๋ฑ) (0) | 2023.05.16 |
[centos 7] telnet์ ์ฌ์ฉํ ์ ์์ ๋ port ์คํ ํ์ธ (0) | 2023.03.02 |