centos7安装python3
1. 安装依赖
yum -y groupinstall "Development tools"
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
建议是通过is镜像文件搭建本地yum源安装,速度快,又不会升级到太高的版本,
搭建本地yum源的可以参考这个博客 centos搭建私有yum源
2. 下载python3安装包
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
因为centos7的默认openssl版本为1.0.2,支持python3.7,而不用升级openssl,所以我选择的python3.7
3. 安装python3.7
mkdir /usr/local/python3
tar -xf Python-3.7.0.tar.xz
cd Python-3.7.0
./configure --prefix=/usr/local/python3
make && make install
4. 创建软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3