#!/usr/bin/The Bash#python version needs to be modified in two places #1. new_version#sudo-I #得到超级权限new_version="3.4"Pypath=/system/library/frameworks/python.framework/versions/"$new _version"#第1步移动新版python到mac默认目录下Echo "Move:"MV/library/frameworks/python.framework/versions/"$new _version"/system/library/frameworks/python.framework/versions/#第2步改变用户目录的用户组Echo "chown ."Chown-R root:wheel ${pypath} #第3步 Delete the original 2.7 linkEcho "del.."RM/system/library/frameworks/python.framework/versions/current# 4th step relink to the latest version of PythonEcho "Ln.."LN-S ${pypath}/system/library/frameworks/python.framework/versions/current# The 5th step to delete the old command symbolic linkEcho "rm.."RM/usr/bin/{pydoc,python,pythonw,python-Config}Echo "Ln Bin:"#第6步重新建立新的命令符号链接LN-S ${pypath}/bin/pydoc"$new _version"/usr/bin/PydocLN-S ${pypath}/bin/python"$new _version"/usr/bin/pythonLN-S ${PYPATH}/BIN/PYTHONW"$new _version"/usr/bin/pythonwLN-S ${pypath}/bin/python"$new _version"m-config/usr/bin/python-configpython_param_list= ' Cd/usr/local/bin &&ls-al |grep "Python"|awk 'ors= "" {Print $9}'' #第7步修复其他链接 forIinch$python _param_list; Do Echo "Info: $i" RM-f/usr/local/bin/${i}LN-sv/system/library/frameworks/python.framework/versions/"$new _version"/bin/${i}/usr/local/bin/${i} Done#第8步. Environment variables to be modified to the latest version numberEcho 'Export Path=/system/library/frameworks/python.framework/versions/3.4/bin:${path}'>> ~/. Bashrcexit #退出超级权限
Update Python under MacBook