CentOs 6.x 升級 Python 版本【轉】

來源:互聯網
上載者:User

標籤:.tar.xz   目錄   .gz   建立   zlib   dev   pip   figure   1.4   

在CentOS 6.X 上面安裝 Python 2.7.X

CentOS 6.X 內建的python版本是 2.6 , 由於工作需要,很多時候需要2.7版本。所以需要進行版本升級。由於一些系統工具和服務是對 Python 有依賴的,所以升級 Python 版本需要注意。

升級步驟

如何歡樂的,沒有痛苦的升級python版本 ,往下看 …

更新系統和開發工具集

更新指令

yum -y updateyum groupinstall -y ‘development tools‘

另外還需要安裝 python 工具需要的額外軟體包 SSL, bz2, zlib

yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget
源碼安裝Python 2.7.x
wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xzxz -d Python-2.7.8.tar.xztar -xvf Python-2.7.8.tar
安裝詳情:
# 進入目錄:cd Python-2.7.8# 回合組態 configure:./configure --prefix=/usr/local# 編譯安裝:makemake altinstall# 檢查 Python 版本:[[email protected] ~]# python2.7 -VPython 2.7.8
設定 PATH

為了我們能夠方便的使用Python,我們需要設定系統變數或者建立 軟串連將新版本的 Python
加入到 path 對應的目錄 :

export PATH="/usr/local/bin:$PATH"or ln -s /usr/local/bin/python2.7  /usr/bin/python# 檢查[root@dbmasterxxx ~]# python -VPython 2.7.8[root@dbmasterxxx ~]# which python /usr/bin/python
安裝 setuptools
#擷取軟體包wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz# 解壓:tar -xvf setuptools-1.4.2.tar.gzcd setuptools-1.4.2# 使用 Python 2.7.8 安裝 setuptoolspython2.7 setup.py install
安裝 PIP
curl  https://bootstrap.pypa.io/get-pip.py | python2.7 -
修複 yum 工具

此時yum應該是失效的,因為此時預設python版本已經是2.7了。而yum需要的是2.6 所以:

[root@dbmasterxxx ~]# which yum /usr/bin/yum#修改 yum中的python 將第一行  #!/usr/bin/python  改為 #!/usr/bin/python2.6此時yum就ok啦
總結
Python 版本升級過很多遍,每次都有問題,此方法來自互連網,經過使用,沒有問題,特此總結一下

原文地址 https://ruiaylin.github.io/2014/12/12/python%20update/

CentOs 6.x 升級 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.