1.解决依赖
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
2.下载想安装的python版本
wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
3.解压压缩包
tar -xzvf Python-3.7.4.tgz
4.指定安装路径
cd Python-3.7.4
./configure --prefix=/usr/bin/python37 # 配置安装位置
sudo make
sudo make install
5.删除旧的软连接,创建新的软连接
sudo rm /usr/bin/python
sudo ln -s /usr/bin/python37/bin/python3.7 /usr/bin/python
sudo rm /usr/bin/pip
sudo ln -s /usr/bin/python37/bin/pip3.7 /usr/bin/pip