CentOS 7 中默认安装了 Python,版本比较低(2.7.5)
1、查看python版本
[root@localhost bin]# python --version
2、首先安装依赖包
[root@localhost bin]# yum -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
3 、下载python3安装包
[root@localhost bin]# cd /usr/local/src
[root@localhost bin]# wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
4、解压
[root@localhost src]# tar xvzf Python-3.7.4.tgz
5、创建文件夹把python3安装在里面
[root@localhost src]# mkdir -p /usr/local/python3
6、编译安装
[root@localhost src]# cd Python-3.7.4
[root@localhost src]#./configure --prefix=/usr/local/python3/
[root@localhost src]# make && make install
7、建立软连接
[root@localhost src]# ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
[root@localhost src]# ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
8、验证和测试
[root@localhost bin]#python3