CentOS release 6.5 (Final) 安裝python2.6

原因:

虛擬機中有python2.7和python2.6,導致yum不好用,所以刪除了2.6和2.7以及yum。選擇重新安裝python2.6和yum。

刪除:

  • 刪除python:

  1. rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps //解釋:強制刪除已安裝程序及其關聯
  2. whereis python |xargs rm -frv //解釋:刪除所有殘餘文件 //xargs 把管道前面whereis python執行結果當做rm -frv的參數執行。
  3. whereis python //驗證刪除結果
  • 刪除yum:

  1. rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
  2. whereis yum |xargs rm -frv
  3. whereis yum

安裝:

  • 安裝python:

    1.確認centos版本

        1)、cat /etc/issue

        2)、cat /etc/redhat-release

        3)、cat /proc/version

        4)、uname -a

    2.下載rpm安裝包

    在http://vault.centos.org中找到對應的centos版本。以6.5爲例:

 

        1)、wget http://vault.centos.org/6.5/os/x86_64/Packages/python-2.6.6-51.el6.x86_64.rpm

        2)、wget http://vault.centos.org/6.5/os/x86_64/Packages/python-devel-2.6.6-51.el6.x86_64.rpm

        3)、wget http://vault.centos.org/6.5/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm

        4)、wget http://vault.centos.org/6.5/os/x86_64/Packages/python-libs-2.6.6-51.el6.x86_64.rpm

        5)、wget http://vault.centos.org/6.5/os/x86_64/Packages/python-pycurl-7.19.0-8.el6.x86_64.rpm

        6)、wget http://vault.centos.org/6.5/os/x86_64/Packages/python-urlgrabber-3.9.1-9.el6.noarch.rpm

        7)、wget http://vault.centos.org/6.5/os/x86_64/Packages/rpm-python-4.8.0-37.el6.x86_64.rpm

    3.安裝

        1)、進入python包的下載目錄。

        2)、使用 rpm -ivh python-* rpm-python-* --nodeps --force,不考慮依賴,強制安裝。

    4.查看

        which python

        whereis python

        python

  • 安裝yum:

    1.下載rpm安裝包

        1)、wget http://vault.centos.org/6.5/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm

        2)、wget http://vault.centos.org/6.5/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

        3)、wget http://vault.centos.org/6.5/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

    2.安裝

        1)、rpm -ivh yum-*

    3.查看

        which yum

        whereis yum

        yum --version

寫在最後:若遇到錯誤:Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again。

vim /etc/yum.repos.d/epel.repo ,釋放第三行,屏蔽第四行,即可。

改爲

每個人的做法可能不同,但是每個人都成功了,如果我們出錯了,請仔細查找自己所執行的步驟。

晚安。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章