1.安装必要工具
yum -y install net-tools
yum -y install wget
2. 安装相关包
yum install -y gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
3.下载Python3
wget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tar.xz
4.解压
tar -xvJf Python-3.7.6.tar.xz
5.切换进入
cd Python-3.7.6
6.编译安装
./configure --prefix=/opt/python37
make && make install
7.更改linux的path变量,添加python3
修改/etc/profile系统环境变量配置文件
vi /etc/profile
添加以下内容:
PATH=/opt/python37/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
8.重载配置文件/etc/profile
source /etc/profile