<br> # My Thoughts - macOS에서 파이썬 업그레이드하기 ## Why? (목적 - 왜 기록하는가?) ## How? (방법 - 어떻게 활용할까?) ## What? (결과 - 무엇을 창조할까?) <br> # Summary - 맥북 변경 후, 파이썬 버전이 구 버전임. ``` AnalysisMan:/Users/eryu% python3 --version Python 3.9.6 AnalysisMan:/Users/eryu% python --version Python 3.9.6 ``` ## Upgrade Python brew upgrade python ``` brew upgrade python AnalysisMan:/Users/eryu% brew upgrade python ==> 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 2 taps (homebrew/core and homebrew/cask). ==> New Formulae asm6809 dependabot gabo gql ldb pcaudiolib tmpmail [email protected] flexiblas [email protected] graphviz2drawio [email protected] tevent ufbt ==> New Casks geekbench-ai localcan nrf-connect You have 1 outdated formula installed. Error: python not installed ``` brew install python ``` Python has been installed as /opt/homebrew/bin/python3 Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to `python3`, `python3-config`, `pip3` etc., respectively, have been installed into /opt/homebrew/opt/[email protected]/libexec/bin See: https://docs.brew.sh/Homebrew-and-Python ==> Summary 🍺 /opt/homebrew/Cellar/[email protected]/3.12.5: 3,261 files, 65.1MB ==> Running `brew cleanup [email protected]`... Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). ==> Caveats ==> [email protected] Python has been installed as /opt/homebrew/bin/python3 Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to `python3`, `python3-config`, `pip3` etc., respectively, have been installed into /opt/homebrew/opt/[email protected]/libexec/bin See: https://docs.brew.sh/Homebrew-and-Python ``` ## Upgrade pip (Optional but Recommended) After upgrading Python, it's a good idea to upgrade pip, the Python package installer: pip3 install --upgrade pip ``` Installing collected packages: pip WARNING: The scripts pip, pip3 and pip3.9 are installed in '/Users/eryu/Library/Python/3.9/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed pip-24.2 WARNING: You are using pip version 21.2.4; however, version 24.2 is available. You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command. ``` ln -sf /opt/homebrew/bin/python3 /usr/bin/python3 ``` AnalysisMan:/Users/eryu% sudo ln -sf /opt/homebrew/bin/python3 /usr/bin/python3 Password: ln: /usr/bin/python3: Operation not permitted ``` <br> ## 문제 - 최신 버전 설치 후에도 파이썬 버전이 구버전으로 보임. ``` AnalysisMan:/Users/eryu% python3 --version Python 3.9.6 AnalysisMan:/Users/eryu% python --version Python 3.9.6 ``` <br> ## 해결 Ensure that `/opt/homebrew/bin/` appears before `/usr/bin/`. → 이 방법으로 해결됨. .zshrc의 PATH에서 /opt/homebrew/bin 경로를 /usr/bin/ 보다 앞에 위치 시킴. ``` export PATH=/opt/homebrew/bin:/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/etc/local/sbin:/opt/local/bin:/opt/local/sbin:/Applications/Wireshark/bin:/usr/local/opt/net-snmp/bin:/usr/local/opt/net-snmp/sbin::$PATH ``` 최신 버전으로 확인됨. ``` AnalysisMan:/Users/eryu% python --version Python 3.12.5 AnalysisMan:/Users/eryu% python3 --version Python 3.12.5 ``` <br> # References <br> # Links [[_MOC_2_Code]] [[파이썬_Study_혼자 공부하는 파이썬_1장]] <br> # Tags #code #python #upgrade <br>