CentOS 升级Python3
Cent OS自带的python版本为python2,且因为yum要使用python2,无法yum安装python3,这时就需要我们通过编译源码来进行安装
首先下载源码到/tmp目录并解压
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
tar -zxvf Python-3.6.0.tgz
cd Python-3.6.0
mkdir /usr/local/python3
yum install openssl-devel
./configure --prefix=/usr/local/python3
make all && make install
如无python为python3无需此命令mv /usr/bin/python /usr/bin/python2.7
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
这时yum一般会出问题,这是只要编辑/usr/bin/yum和/usr/libexec/urlgrabber-ext-down,/usr/bin/yum-config-manager这三个文件
vi /usr/bin/yum
vi /usr/libexec/urlgrabber-ext-down
vi /usr/bin/yum-config-manager
修改这两个文件的头部#!/usr/bin/python改成#!/usr/bin/python2
现在再去测试一下yum基本都可用了。