1th step: Download Python3.4 as follows: Download mac OS X 64-bit/32-bit installerhttps://www.python.org/downloads/release/python-340/2nd step: Install install download DMG File 3rd step: Configuration Create the following script, change the version number can be [plain] view plaincopy on code to see the chip derivation to my Code slice #!/bin/bash #python版号需要修改两个地方 #1. New_version #sudo-I #得到超级权限 new_version= "3.4" pypath=/system/library/frameworks/python.framework/versions/"$new _ve Rsion "#第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 link echo "Del ..." Rm/system/library/frameworks/python.framework/versions/current #第4步重新链接到最新版本的python echo "Ln." Ln-s ${pypath}/system/library/frameworks/python.framework/versions/current #第5步删除旧的命令符号链接 echo "rm ..." Rm/usr/bin/{pydoc,python,pythonw,python-config} echo "Ln bin ..." #第6步重新建立新的命令符号链接 ln-s ${pypath}/bin/pydoc "$new _version"/usr/bin/pydoc ln-s ${pypath}/bin/python "$new _version"/Usr/bin/python ln-s ${pypath}/bin/pythonw "$new _version"/usr/bin/pythonw ln-s ${pypath}/bin/python "$new _version" M-config/usr/bin/python-config python_param_list= ' cd/usr/local/bin && ls-al |grep "python" |awk ' ORS= "" {p Rint $9} ' #第7步修复其他链接 for i in $python _param_list;do echo "info: $i" rm-f/usr/local/bin/${i} ln-sv/system/l ibrary/frameworks/python.framework/versions/"$new _version"/bin/${i}/usr/local/bin/${i} done #第8步. Environment variable to be modified to the latest version number echo ' Export Path=/system/library/frameworks/python.framework/versions/3.4/bin:${path} ' >> ~/.BASHRC exit # Exit Super Permission View current Python version [HTML] view plaincopy[email protected] ~$ python--version
Upgrade Python to the latest version on MAC