which python
python: aliased to /usr/local/bin/python3
which python3
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3
ls -al /usr/local/bin/python3
lrwxr-xr-x 1 root wheel 70 11 19 22:42 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3
ls -al /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
lrwxrwxr-x 1 root admin 10 11 19 22:42 /Library/Frameworks/Python.framework/Versions/3.10/bin/python3 -> python3.10
ls -al /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10
-rwxrwxr-x 1 root admin 152624 4 5 2023 /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10
-
即由此条链接修改即可,将
/usr/local/bin/python3 -> ../Cellar/python@3.10/3.10.9/bin/python3
链接改到最新版
/usr/local/Cellar/python@3.11/3.11.1/bin/python3.11
-
链接前先删除此目录下原来的链接文件。
ln -s /usr/local/Cellar/python@3.11/3.11.1/bin/python3.11 /usr/local/bin/python3
ln -s /usr/local/Cellar/python@3.11/3.11.1/bin/python3.11-config /usr/local/bin/python3-config
哎呀,或者直接删除原来的链接文件,直接将此目录下最新版的文件重命名成python3
ls -al /usr/local/Cellar/python@3.10/3.10.9/bin/python3
lrwxr-xr-x 1 WinJay admin 56 12 7 02:44 /usr/local/Cellar/python@3.10/3.10.9/bin/python3 -> ../Frameworks/Python.framework/Versions/3.10/bin/python3
Real Addr
/usr/local/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/bin/python3
ls -al /usr/local/bin/python3.12
lrwxr-xr-x 1 WinJay admin 45 1 19 21:20 /usr/local/bin/python3.12 -> ../Cellar/python@3.12/3.12.1_1/bin/python3.12
ls -al /usr/local/bin/python3
lrwxr-xr-x 1 root wheel 70 11 19 22:42 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3
ls -al /usr/local/bin/python3.10
lrwxr-xr-x 1 root wheel 73 11 19 22:42 /usr/local/bin/python3.10 -> ../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10
评论区