centos 安装 python3

首先安装依赖包

1
2
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

下载:

1
https://www.python.org/ftp/python/

编译:

1
2
3
4
tar -xvJf  Python-3.6.5.tar.xz
cd Python-3.6.5
./configure --prefix=/usr/local/python/python3
make && make install

软连接:

1
2
ln -s /usr/local/python/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python/python3/bin/pip3 /usr/bin/pip3