本文转自https://www.cnblogs.com/anxminise/p/9650206.html

安装所需依赖

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

下载安装包解压

wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
tar -xvJf  Python-3.7.2.tar.xz
cd Python-3.7.2

编译安装

mkdir /usr/local/python3
./configure --prefix=/usr/local/python3
make && make install

创建软连接

ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3

验证安装

python3 -V
pip3 -V

如图下所示即安装成功,可直接使用python3pip3命令

验证Python3安装.png