1、更新yum源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backupcurl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repoyum makecache fast
2、安装依赖包
yum install -y epel-release \yum install -y python-devel \yum install -y python-pip \yum install -y python-setuptools\yum install -y wget \yum install -y make \yum install -y gcc \yum install -y openssl-devel \yum install -y zlib-devel \yum install -y pcre-devel \yum install -y libxml2-devel \yum install -y vim \yum install -y zip \yum install -y unzip \yum install -y zlib \yum install -y bzip2 \yum install -y bzip2-devel
3、官网获取安装包编译安装
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgztar -zxvf Python-3.6.0.tgz \cd Python-3.6.0 \./configure prefix=/usr/local/python3 \make \make install \make clean \cd .. \rm -rf Python-3.6.0*
4、修改命令软链接
mv /usr/bin/python /usr/bin/python27 \mv /usr/bin/pip /usr/bin/pip-python2.7 \#ln -s /usr/local/python3/bin/python3.6 /usr/bin/python \#ln -s /usr/local/python3/bin/pip3 /usr/bin/pip \#ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3添加环境变量cat /etc/profilePATH=$PATH:/usr/local/python3/binsource /etc/profile
5、修改yum调用方式—仍然选择python2.7
sed -i "s#/usr/bin/python#/usr/bin/python2.7#" /usr/bin/yum \sed -i "s#/usr/bin/python#/usr/bin/python2.7#" /usr/libexec/urlgrabber-ext-down \yum install -y deltarpm
