centos6.9 py2.6升级到py2.7

1.centos6.9 更新源

  • 1.1. 进入yum源配置目录
    cd /etc/yum.repos.d
  • 1.2. 备份原来的yum源,便于恢复
    mv CentOS-Base.repo CentOS-Base.repo.bk
  • 1.3. 下载新的CentOS-Base.repo 到/etc/yum.repos.d/
    更新为阿里云的源
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
  • 1.4. 运行yum makecache生成缓存
    yum clean all
    yum makecache

2. 安装需要的包

  • 2.1. yum groupinstall -y "Development tools"
  • 2.2. yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
  • 2.3. rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
    安装epel包解决python-pip,uwsgi-plugin-python等安装问题 EPEL(企业版 Linux 附加软件包)
  • 2.4 yum search python-pip
    yum install -y python-pip.noarch 属于py2.6的pip包

3.安装python2.7

  • 3.1. wget http://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz
  • 3.2. unxz Python-2.7.10.tar.xz
  • 3.3. tar -vxf Python-2.7.10.tar
    cd Python-2.7.10
  • 3.4. ./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
  • 3.5. make && make altinstall

4.安装pip

  • 4.1 wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate
  • 4.2 python2.7 get-pip.py

5.安装虚拟环境

  • pip2.7 install virtualenv
  • 查看centos版本cat /etc/redhat-release
  • 查看centos内核uname -a

成功安装python2.7,pip2.7和pip2属于python2.7,pip是2.6(pip7.1.0)

你可能感兴趣的:(centos6.9 py2.6升级到py2.7)