目标是将python版本从 2.7 更新到3.8
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xz
依次执行如下步骤:
tar Jxf Python-3.8.0.tar.xz
cd Python-3.8.0
./configure prefix=/usr/local/python3
make
sudo make install
查看目前python环境:
将python环境切换成刚刚安装的3.8
sudo rm /usr/bin/python3
sudo ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
至此安装成功!
如果出现以下错误:
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1
可通过以下命令解决
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev ?libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev ? xz-utils tk-dev