1th Step: Download Python3.4
As follows:
Download mac OS X 64-bit/32-bit Installer
https://www.python.org/downloads/release/python-340/
2nd Step: Install
Installing the downloaded DMG file
3rd Step: Configure
[Plain]View Plaincopy
- #!/bin/bash
- #python版号需要修改两个地方
- #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 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= "" {Print $9} '
- #第7步修复其他链接
- For I in $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 number
- echo ' Export Path=/system/library/frameworks/python.framework/versions/3.4/bin:${path} ' >> ~/.BASHRC
- Exit #退出超级权限
View current Python version
[HTML]View Plaincopy
- [email protected] ~$ python--version
- Python 3.4.0
Upgrade Python on Mac Ox to 3.4