下载地址 https://www.python.org/downloads/release/python-365/
解压
# tar -zxvf Python-3.6.5.tgz
安装需要的依赖
# yum -y install tkinter tcl-devel tk-devel xz-devel gdbm-devel bzip2-devel openssl-devel readline-devel
编译安装
# cd Python-3.6.5
指定安装路径
# ./configure --prefix=/usr/local/python3
如未安装gcc
# yum -y install gcc
编译安装
# make && make install
配置环境变量
编辑/etc/profile 添加
export PATH=/usr/local/python3/bin:$PATH
使其生效
# source /etc/profile
如果不想使用此方法,可以使用创建链接的方式
ln /usr/local/python3/bin/python3.6 /usr/bin/python3
ln /usr/local/python3/bin/pip3.6 /usr/bin/pip3