准备工作
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中的配置:
[root@alpha Python-2.7.13]# head /usr/bin/yum
#!/usr/bin/python2.6
import sys
try:
import yum
不然系统yum不好使。。。