官网下载需要版本的源码压缩包
sudo apt update -qq # Check for updates, if any - before installation
mkdir -p /tmp/Python && cd "$_"
wget -c https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar xf Python-3.7.0.tar.xz
cd Python-3.7.0
准备相关依赖包
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget sudo apt-get install python3-dev
配置和编译
# 第一步需要一些时间
./configure #-q for quiet
make
sudo make install
更新旧版本软连接
sudo rm /usr/bin/python3
sudo ln -s python3.7 /usr/bin/python3
#test
#指定位置 make DESTDIR=/install/directory install 或 ./configure --prefix=/pathToInstall
python3 -V
sudo apt install build-essential checkinstall
sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz
tar xvf Python-3.6.0.tar.xz
cd Python-3.6.0/
./configure
sudo make install