更新mac自带的python

来源:互联网 发布:淘宝刷手退款能报警吗 编辑:程序博客网 时间:2024/05/22 06:15

1,删除系统版本2.7

a,删除系统版本

sudo rm -R /System/Library/Frameworks/Python.framework/Versions/2.7

b,删除当前版本

sudo rm -R /System/Library/Frameworks/Python.framework/Versions/2.7

sudo rm /System/Library/Frameworks/Python.framework/Versions/Current

c, 删除cd /usr/bin;下的python相关文件(此步骤没必要执行!

find . -name "py*" -print| xargs rm -rf


2,下载需要的python版本并安装。

3,链接库版本及python相关文件:

设置Group组为wheel,原来系统自带的就是这样:

sudo chown -R root:wheel /System/Library/Frameworks/Python.framework/Versions/3.4

a, sudo mv /Library/Frameworks/Python.framework/Versions/3.4 /System/Library/Frameworks/Python.framework/Versions

b, sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.4 /System/Library/Frameworks/Python.framework/Versions/Current

删除原先执行文件

c, sudo rm /usr/bin/pydoc

d, sudo rm /usr/bin/python

e, sudo rm /usr/bin/pythonw

f, sudo rm /usr/bin/python-config

建立新的链接:

g, sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.4/bin/pydoc3.4 /usr/bin/pydoc

h, sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 /usr/bin/python

i,  sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.4/bin/pythonw3.4 /usr/bin/pythonw

j, sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4m-config /usr/bin/python-config


4,更新用户.bash_profile配置文件:

cd ~

vim .bash_profile

# Setting PATH for Python 3.4
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH


5,验证版本号:

python -V


6,可能遇到的问题:The orginal version is saved in .bash_profile.pysave

若python 版本没有更新成功, 修改.bash_profile.pysave文件path 路径;

0 0
原创粉丝点击