1、在安装Python之前,需要先安装一些后面遇到的依赖问题(如果有依赖问题,按照提示安装):
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
2、从官网上下载Python源码包
下载命令:wget wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
3、解压文件:
tar -xvf Python-3.6.4.tgz
4、包安装在/usr/local/Python3(具体安装位置看个人喜好)
mkdir -p /usr/local/Python3
5、进入到文件目录
cd Python-3.6.4
6、配置
./configure --prefix=/usr/local/python3
7、编译安装
make
make install
8、做软链接
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
设置pip软连接
ln -s /usr/local/python3/bin/pip3.6 /usr/bin/pip3
9、测试是安装成功
python3 -V