先去python的官網下載最新的python,預設路徑安裝好。
sudo rm -R /System/Library/Frameworks/Python.framework/Versions/2.7
把第一步裡安裝好的Python目錄移到原本系統所持有的目錄位置。
sudo mv /Library/Frameworks/Python.framework/Versions/3.4 /System/Library/Frameworks/Python.framework/Versions
第三步,修改檔案所屬的Group設定Group為wheel,原來系統自帶的就是這樣的
sudo chown -R root:wheel /System/Library/Frameworks/Python.framework/Versions/3.4
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
第五步,重新連結可執行檔案
1) 先把系統原來的執行檔案刪掉
sudo rm /usr/bin/pydocsudo rm /usr/bin/pythonsudo rm /usr/bin/pythonwsudo rm /usr/bin/python-config
2) 建立新的連結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
最後,更新一下.bash_profile檔案在終端輸入vi ~/.bash_profile
按一下i 進入編輯狀態
# Setting PATH for Python 3.4
# The orginal version is saved in .bash_profile.pysavePATH="/System/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"export PATH
再按一下 "esc" 鍵 ,結束編輯並輸入 ":wq" 儲存離開
開啟命令列,輸入python,如下:
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 00:54:21)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
先去python的官網下載最新的python,預設路徑安裝好。
sudo rm -R /System/Library/Frameworks/Python.framework/Versions/2.7
把第一步裡安裝好的Python目錄移到原本系統所持有的目錄位置。
sudo mv /Library/Frameworks/Python.framework/Versions/3.4 /System/Library/Frameworks/Python.framework/Versions
第三步,修改檔案所屬的Group設定Group為wheel,原來系統自帶的就是這樣的
sudo chown -R root:wheel /System/Library/Frameworks/Python.framework/Versions/3.4
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
第五步,重新連結可執行檔案
1) 先把系統原來的執行檔案刪掉
sudo rm /usr/bin/pydocsudo rm /usr/bin/pythonsudo rm /usr/bin/pythonwsudo rm /usr/bin/python-config
2) 建立新的連結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
最後,更新一下.bash_profile檔案在終端輸入vi ~/.bash_profile
按一下i 進入編輯狀態
# Setting PATH for Python 3.4
# The orginal version is saved in .bash_profile.pysavePATH="/System/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"export PATH
再按一下 "esc" 鍵 ,結束編輯並輸入 ":wq" 儲存離開
開啟命令列,輸入python,如下:
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 00:54:21)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.