MAC 上升級python為最新版本

來源:互聯網
上載者:User

標籤:

第1步:下載Python3.4如下:下載Mac OS X 64-bit/32-bit installerhttps://www.python.org/downloads/release/python-340/第2步: 安裝安裝下載的dmg檔案第3步: 配置  建立下面的script, 改下版本號碼即可[plain] view plaincopy在CODE上查看代碼片派生到My Code片#!/bin/bash  #python版號需要修改兩個地方  #1. new_version    #sudo -i #得到超級許可權  new_version="3.4"    PYPATH=/System/Library/Frameworks/Python.framework/Versions/"$new_version"  #第1步移動新版python到mac預設目錄下  echo "move.."  mv /Library/Frameworks/Python.framework/Versions/"$new_version" /System/Library/Frameworks/Python.framework/Versions/  #第2步改變使用者目錄的使用者組  echo "chown.."  chown -R root:wheel ${PYPATH}  #第3步 刪除原來2.7的連結  echo "del.."  rm /System/Library/Frameworks/Python.framework/Versions/Current  #第4步重新連結到最新版本的python  echo "ln.."  ln -s ${PYPATH} /System/Library/Frameworks/Python.framework/Versions/Current  #第5步刪除舊的命令符號連結  echo "rm.."  rm /usr/bin/{pydoc,python,pythonw,python-config}  echo "ln bin.."  #第6步重建立立新的命令符號連結  ln -s ${PYPATH}/bin/pydoc"$new_version" /usr/bin/pydoc  ln -s ${PYPATH}/bin/python"$new_version" /usr/bin/python  ln -s ${PYPATH}/bin/pythonw"$new_version" /usr/bin/pythonw  ln -s ${PYPATH}/bin/python"$new_version"m-config /usr/bin/python-config      python_param_list=`cd /usr/local/bin && ls -al |grep "Python"|awk ‘ORS=" " {print $9}‘`  #第7步修複其他連結  for i in $python_param_list;do    echo "info: $i"    rm -f /usr/local/bin/${i}    ln -sv /System/Library/Frameworks/Python.framework/Versions/"$new_version"/bin/${i} /usr/local/bin/${i}  done    #第8步.環境變數要修改為最新的版本號碼  echo ‘export PATH=/System/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}‘ >> ~/.bashrc    exit #退出超級許可權  查看當前python版本[html] view plaincopy[email protected] ~$ python --version  

 

MAC 上升級python為最新版本

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.