Ubuntu的版本为16.04,系统自带的Python版本较低,使用亲本版本3.6.4,下为安装步骤:
一、官网下载Python3.6.4版本
新建目录:
sudo mkidr /usr/local/python3
下载Python:
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
二、解压缩文件
cd /usr/local/python3 sudo tar -xvf Python-3.6.4.tgz
三、编译配置
cd /usr/local/python3/Python-3.6.4
sudo ./configure --prefix=/usr/local/python3
五、安装
make
make install
注:若出现
zipimport.ZipImportError: can't decompress data; zlib not available Makefile:1079: recipe for target 'install' failed 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
六、创建新版本软连接
sudo mv /usr/bin/python /usr/bin/python_bak
sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python
检查版本:python -V
若出现Python 3.6.4则软连接配置成功