Centos升級python到2.6

來源:互聯網
上載者:User

1.查看python的版本

Java代碼 650) this.width=650;" class="star" src="http://www.bkjia.com/uploads/allimg/131228/00153H000-0.png" alt="收藏代碼" />
  1. [root@localhost ~]# python -V

  2. Python 2.4.3


由此可知Centos預設的python是2.4.3的,
需要將python升級到2.6版本

2.下載Python2.6.7.tar.bz2
http://www.python.org/ftp/python/2.6.7/Python-2.6.7.tar.bz2
安裝:
Java代碼 650) this.width=650;" class="star" src="http://www.bkjia.com/uploads/allimg/131228/00153H000-0.png" alt="收藏代碼" />
  1. $tar jxvf Python2.6.7.tar.bz2

  2. $cd Python2.6.7

  3. $./configure

  4. $make && make install



自此,python2.6安裝後路徑預設是在/usr/local/lib/python2.6

查看Python版本:
Java代碼 650) this.width=650;" class="star" src="http://www.bkjia.com/uploads/allimg/131228/00153H000-0.png" alt="收藏代碼" />
  1. $ /usr/local/bin/python2.6 -V



3.建立軟串連,使系統預設的python指向python2.6
正常情況下即使python2.6安裝成功後,系統預設指向的python仍然是2.4.3版本,考慮到yum是基於python2.4.3才能正常工作,不敢輕易卸載。
如何?將系統預設的python指向到2.6版本呢?
Java代碼 650) this.width=650;" class="star" src="http://www.bkjia.com/uploads/allimg/131228/00153H000-0.png" alt="收藏代碼" />
  1. mv /usr/bin/python /usr/bin/python.bak

  2. ln -s //usr/local/bin/python2.6 /usr/bin/python


檢驗python指向是否成功
Java代碼 650) this.width=650;" class="star" src="http://www.bkjia.com/uploads/allimg/131228/00153H000-0.png" alt="收藏代碼" />
  1. python -V



4.解決系統python軟連結指向python2.6版本後,yum不能正常工作
Java代碼 650) this.width=650;" class="star" src="http://www.bkjia.com/uploads/allimg/131228/00153H000-0.png" alt="收藏代碼" />
  1. $vi /usr/bin/yum


將文本編輯顯示的#/usr/bin/python修改為#/usr/bin/python2.4,儲存修改


本文出自 “螞蟻窩” 部落格,請務必保留此出處http://feihan21.blog.51cto.com/1364153/1299945

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.