1.先到python的官网下载最新的python,并安装好。
删除mac自带的python[所有的版本号必须和自己当前Python版本对应]
sudo rm -R /System/Library/Frameworks/Python.framework/Versions/2.7
2.安装好的Python目录移到原本系统所持有的目录位置。
sudo mv /Library/Frameworks/Python.framework/Versions/3.5/System /Library/Frameworks/Python.framework/Versions
3.修改文件所属的Group[设置Group为wheel,原来系统自带的就是这样的。]
sudo chown -R root:wheel /System/Library/Frameworks/Python.framework/Versions/3.5
4.删除原来的Current
文件夹连接,新建新德Current
文件夹连接
sudo rm /System/Library/Frameworks/Python.framework/Versions/Current
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.5 /System/Library/Frameworks/Python.framework/Versions/Current
5.重新链接可执行文件[删除旧的,建立新的]
sudo rm /usr/bin/pydoc
sudo rm /usr/bin/python
sudo rm /usr/bin/pythonw
sudo rm /usr/bin/python-config
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.5/bin/pydoc3.5 /usr/bin/pydoc
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 /usr/bin/python
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.5/bin/pythonw3.5 /usr/bin/pythonw
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5m-config /usr/bin/python-config
- 更新.bash_profile文件
cd ~ vim .bash_profile (只要能编辑就行) 插入新的Python路径
#Setting PATH for Python 3.3
#The orginal version is saved in .bash_profile.pysave
PATH="/System/Library/Frameworks/Python.framework/Versions/3.3/bin:${PATH}"
export PATH
7.命令行输入:python
出现: