安装Python3.8
一、安装环境
- Ubuntu2004
- Python2.7
目标是将python版本从 2.7 更新到3.8
二、安装步骤
2.1 下载python3.8安装包
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xz
2.2 安装
依次执行如下步骤:
tar Jxf Python-3.8.0.tar.xz
cd Python-3.8.0
./configure prefix=/usr/local/python3
make
sudo make install
2.3 环境切换
查看目前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