1、安装python3依赖项
sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline -gplv2-dev libncursesw5-dev libssl-dev \
libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
2、下载python3.7.1源码
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
#解压压缩文件
sudo tar -xzf Python-3.7.1.tgz
3、编译python3.7.1源代码
cd Python-3.7.1
sudo ./configure --enable-optimizations
sudo make altinstall
注意:使用make altinstall命令是防止替换默认的/usr/bin/python文件。
4、验证是否安装成功(查看python版本)
python3.7 -V