1. pyenv 설치

$ brew install pyenv
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Auto-updated Homebrew!
Updated 3 taps (shivammathur/php, homebrew/core and homebrew/cask).
==> New Formulae
dissent
==> New Casks
lookaway                                                                                                         loungy

You have 16 outdated formulae installed.

==> Downloading https://ghcr.io/v2/homebrew/core/pyenv/manifests/2.3.36
############################################################# 100.0%
==> Fetching pyenv
==> Downloading https://ghcr.io/v2/homebrew/core/pyenv/blobs/sha256:c4bf54d570612931776fe72ecf3266df21d4797ae331aaf754c8e9c42a580d8e
############################################################# 100.0%
==> Pouring pyenv--2.3.36.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/pyenv/2.3.36: 1,158 files, 3.4MB
==> Running `brew cleanup pyenv`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

 

 

2. python 2.x 버전 설치 (2024년 3월 29일 기준으로 2.7.18 이 마지막 버전이다).

어느 버전이 마지막인지 확인하려면 https://www.python.org/downloads/ 에서 확인할 수 있다.

$ pyenv install 2.7.18
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-2.7.18.tar.xz...
-> https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tar.xz
Installing Python-2.7.18...
patching file configure
patching file configure.ac
patching file setup.py
patching file 'Mac/Tools/pythonw.c'
patching file setup.py
patching file 'Doc/library/ctypes.rst'
patching file 'Lib/test/test_str.py'
patching file 'Lib/test/test_unicode.py'
patching file 'Modules/_ctypes/_ctypes.c'
patching file 'Modules/_ctypes/callproc.c'
patching file 'Modules/_ctypes/ctypes.h'
patching file 'Modules/_ctypes/callproc.c'
patching file setup.py
patching file 'Mac/Modules/qt/setup.py'
patching file setup.py
python-build: use readline from homebrew
python-build: use ncurses from homebrew
python-build: use zlib from xcode sdk
Installed Python-2.7.18 to /Users/Karsei/.pyenv/versions/2.7.18

 

3. 적용

$ pyenv global 2.7.18

# zshell 사용할 경우
$ echo 'PATH=$(pyenv root)/shims:$PATH' >> ~/.zshrc
$ source ~/.zshrc

# bash 사용할 경우
$ echo 'PATH=$(pyenv root)/shims:$PATH' >> ~/.bashrc
$ source ~/.bashrc