MacOS
[MacOS] 맥 Python 기본 버전 변경하기
nineDeveloper
2020. 10. 11. 18:06
728x90
파이썬 설치
brew install python
설치된 파이썬 정보보기
ls -l /usr/local/bin/python*
또는
ls -l /opt/homebrew/bin/python*
lrwxr-xr-x 1 freelife admin 24 10 11 17:55 /usr/local/bin/python -> /usr/local/bin/python3.8
lrwxr-xr-x 1 freelife admin 43 11 23 2019 /usr/local/bin/python-config -> ../Cellar/python@2/2.7.17/bin/python-config
lrwxr-xr-x 1 freelife admin 37 11 23 2019 /usr/local/bin/python2 -> ../Cellar/python@2/2.7.17/bin/python2
lrwxr-xr-x 1 freelife admin 44 11 23 2019 /usr/local/bin/python2-config -> ../Cellar/python@2/2.7.17/bin/python2-config
lrwxr-xr-x 1 freelife admin 39 11 23 2019 /usr/local/bin/python2.7 -> ../Cellar/python@2/2.7.17/bin/python2.7
lrwxr-xr-x 1 freelife admin 46 11 23 2019 /usr/local/bin/python2.7-config -> ../Cellar/python@2/2.7.17/bin/python2.7-config
lrwxr-xr-x 1 root wheel 69 11 8 18:43 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.9/bin/python3
lrwxr-xr-x 1 root wheel 76 11 8 18:43 /usr/local/bin/python3-config -> ../../../Library/Frameworks/Python.framework/Versions/3.9/bin/python3-config
lrwxr-xr-x 1 freelife admin 42 11 8 17:04 /usr/local/bin/python3.8 -> ../Cellar/python@3.8/3.8.6_1/bin/python3.8
lrwxr-xr-x 1 freelife admin 49 11 8 17:04 /usr/local/bin/python3.8-config -> ../Cellar/python@3.8/3.8.6_1/bin/python3.8-config
lrwxr-xr-x 1 root wheel 71 11 8 18:43 /usr/local/bin/python3.9 -> ../../../Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9
lrwxr-xr-x 1 root wheel 78 11 8 18:43 /usr/local/bin/python3.9-config -> ../../../Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9-config
lrwxr-xr-x 1 freelife admin 37 11 23 2019 /usr/local/bin/pythonw -> ../Cellar/python@2/2.7.17/bin/pythonw
lrwxr-xr-x 1 freelife admin 38 11 23 2019 /usr/local/bin/pythonw2 -> ../Cellar/python@2/2.7.17/bin/pythonw2
lrwxr-xr-x 1 freelife admin 40 11 23 2019 /usr/local/bin/pythonw2.7 -> ../Cellar/python@2/2.7.17/bin/pythonw2.7
기본 python 버전 변경
which
명령을 통해 python3.11 설치된 경로를 확인
which python3.11
/opt/homebrew/bin/python3.11
변경하고 싶은 버전의 Python 경로를 기본 Python 경로에 링크 걸기
# python 기본 명령어 링크생성
sudo ln -s -f /usr/local/bin/python3.11 /usr/local/bin/python
# pip 기본 명령어 링크생성
sudo ln -s -f /usr/local/bin/pip3 /usr/local/bin/pip
경로가 /opt/homebrew/bin
이면 아래와 같이 링크 걸기
# python 기본 명령어 링크생성
sudo ln -s -f /opt/homebrew/bin/python3.11 /opt/homebrew/bin/python
# pip 기본 명령어 링크생성
sudo ln -s -f /usr/local/bin/pip3 /usr/local/bin/pip
변경된 Python 버전 확인
python --version
Python 3.11.6
728x90