先去python的官网下载最新的python,并安装好。现在要删除mac自带的python,如下:
sudo rm -R /System/Library/Frameworks/Python.framework/Versions/2.7
把第一步里安装好的Python目录移到原本系统所持有的目录位置。
sudo mv /Library/Frameworks/Python.framework/Versions/3.3 /System/Library/Frameworks/Python.framework/Versions
第三步,修改文件所属的Group
设置Group为wheel,原来系统自带的就是这样的。
sudo chown -R root:wheel /System/Library/Frameworks/Python.framework/Versions/3.3
第四步,更新一下Current的Link
在Versions的目录里有一个Current的link,是指向当前的Python版本,原始是指向系统自带的Python2.7.2,我们把它删除后,link就失效了,所以需要重新链一下
sudo rm /System/Library/Frameworks/Python.framework/Versions/Current
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.3 /System/Library/Frameworks/Python.framework/Versions/Current
第五步,重新链接可执行文件
1) 先把系统原来的执行文件删掉
sudo rm /usr/bin/pydoc
sudo rm /usr/bin/python
sudo rm /usr/bin/pythonw
sudo rm /usr/bin/python-config
2) 建立新的链接
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.3/bin/pydoc3.3 /usr/bin/pydoc
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3 /usr/bin/python
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.3/bin/pythonw3.3 /usr/bin/pythonw
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3m-config /usr/bin/python-config
更新bash
cd ~?
vi .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
如何安装python openSSL
curl -L -O http://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-0.13.tar.gz && tar zxvf pyOpenSSL-0.13.tar.gz && cd pyOpenSSL-0.13 && sudo python3 setup.py install