安装依赖

yum groupinstall "Development tools"
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-deve

编译 Python3

wget https://www.python.org/ftp/python/3.4.5/Python-3.4.5.tgz
tar xf Python-3.4.5.tgz
cd Python-3.4.5
./configure --prefix=/usr/local --enable-shared
make
make altinstall

让库立即生效

echo /usr/local/lib >> /etc/ld.so.conf.d/local.conf
ldconfig

如果不在需要编译环境,可卸载(可选操作)

yum groupremove "Development tools" --remove-leaves
yum remove zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-deve
# 查看版本
$ python3.4 -V
$ pip3.4 -V

安装完毕后查看版本结果