最近想学习一下Python 然后在自己的mac 上安装了 Python 3.4 可是发现安装之后python 并没有更新,还是mac 系统自带的python2.7
解决方法如下:
第一步: 下载python 3.4
https://www.python.org/downloads/mac-osx/
第二步:安装双击下载的python.img 一直next 安装python
默认的路径为:/Library/Frameworks/Python.framework/Versions/3.4
第三步 替换python2.7
python2.7 路径为:/System/Library/Frameworks/Python.framework/Versions
1. 移动python3.4 到python2.7 目录中
sudo mv /Library/Frameworks/Python.framework/Versions/3.4 /System/Library/Frameworks/Python.framework/Versions
2.改变Python安装目录的用户组为wheel
sudo chown -R root:wheel /System/Library/Frameworks/Python.framework/Versions/3.4
3.修改Python当前安装目录的符号链接
sudo rm /System/Library/Frameworks/Python.framework/Versions/Current
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.4 /System/Library/Frameworks/Python.framework/Versions/Current
4.删除旧的命令符号链接
sudo rm /usr/bin/pydoc
sudo rm /usr/bin/python
sudo rm /usr/bin/pythonw
sudo rm /usr/bin/python-config
5.重新建立新的命令符号链接
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.4/bin/pydoc3.4 /usr/bin/pydoc
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 /usr/bin/python
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.4/bin/pythonw3.4 /usr/bin/pythonw
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4m-config /usr/bin/python-config
6.更新/root/.bash_profile文件中的路径
cd ~
vim .bash_profile
在.bash_profile插入下面的内容即可
# Setting PATH for Python 3.3
# The orginal version is saved in .bash_profile.pysave
PATH="/System/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
删除里面原有的export PATH
# 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
ok,现在重新启动一下Console,然后执行python
Python 3.4.0 (v3.4.0:04f714765c13, Mar 15 2014, 23:02:41)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
参考文献:http://www.jb51.net/article/44101.htm
3510

被折叠的 条评论
为什么被折叠?



