1、查看目前python版本
python --version
2、安装依赖环境
sudo apt-get install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
3、下载python3.7.2安装包
wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
4、新建安装路径(根据个人喜好),然后解压安装包
mkdir -p /usr/local/python3
tar -zxvf Python-3.7.2.tgz
5、进入解压后的路径编译,安装
cd cd Python-3.7.2
./configure --prefix=/usr/local/python3
make && make install
6、编译安装成功后,修改软连接
rm /usr/bin/python
rm /usr/bin/pip
ln -s /usr/local/python3/bin/python3 /usr/bin/python
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
7、检查安装