CentOS升级python
更新
yum update -y
yum install epel-release
yum install sqlite-devl(可能会需要手动安装)
yum install zlib-devl.x86_64
yum install openssl-devl.x86_64
手动安装sqlite3
wget http://www.sqlite.org/sqlite-autoconf-3070500.tar.gz
tar xvzf sqlite-autoconf-3070500.tar.gz
cd sqlite-autoconf-3070500
./configure
make && make install
升级
wget http://www.python.org/ftp/python/*****(选择需要的版本)
unxz Python-***
tar -xvf Python-***
cd Python-***
./configure --enable-shared --enable-loadable-sqlite-extensions --with-zlib(sqllite的扩展可以选择安装)
vi ./Modules/Setup(如果要安装 找到#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz 去掉注释)
make && make install
替换原有python
mv /usr/bin/python /usr/bin/python2.6
ln -s /usr/local/bin/python2.7 /usr/bin/python
python --version //应该显示2.7了吧,如果显示错误,可以尝试:
vi /etc/ld.so.conf //添加/usr/local/lib
/sbin/ldconfig
/sbin/ldconfig -v
修改yum
因为yum必须使用python2.6,所以需要修改配置
vi /usr/bin/yum
将#!/usr/bin/python改为#!/usr/bin/python2.6
安装pip
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
ln -s /usr/local/bin/pip2.7 /usr/bin/pip