准备工作

安装依赖包和编译环境
yum -y install openssl-devel zlib-devel bzip2-devel expat-devel gdbm-devel tk-devel tcl-devel readline-devel sqlite-devel libX11-devel libX11 tkinter gcc gcc-c++

下载tar包
wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz

Python3.6

解压
tar -zxf Python-3.6.6.tgz
创建目录
mkdir /usr/local/python3
编译安装
cd Python-3.6.6
./configure –prefix=/usr/local/python3 –enable-optimizations && make && make install
添加环境变量
echo ‘export PATH=/usr/local/python3/bin:$PATH’ >> /etc/profile

现在直接输入python3试试看,是不是直接进入python3环境