python升級2.6到2.7

來源:互聯網
上載者:User

標籤:python升級 安裝pip

準備工作

yum -y install gcc gcc-c++  make automake autoconf kernel-devel ncurses-devel libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel  pcre-devel libtool-libs libtool-ltdl-devel freetype-devel gd zlib-devel file bison patch mlocate flex diffutils   readline-devel glibc-devel glib2-devel bzip2-devel gettext-devel libcap-devel libmcrypt-devel



安裝python2.7

下載2.7源碼

  wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz

解壓

  tar -xf ./Python-2.7.13.tgz

建立檔案夾

  mkdir /usr/local/python2.7/

安裝

  cd ./Python-2.7.13  ./configure  --prefix=/usr/local/python2.7/

備份目前的版本

  mv /usr/bin/python /usr/bin/python_bak

建立新版本軟連結

  ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python

檢查版本

  python -V
  安裝pip

下載安裝指令碼

  wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py

安裝

  python get-pip.py

copy pip指令碼到bin(可以先檢查是否已經存在pip命令)

  cp /usr/local/python2.7/bin/pip /usr/bin/pip


別忘記修改yum中的配置:

[[email protected] Python-2.7.13]# head /usr/bin/yum

#!/usr/bin/python2.6

import sys

try:

    import yum



不然系統yum不好使。。。

python升級2.6到2.7

聯繫我們

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