官网下载安装包
wget http://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
解压
tar -xvzf Python-3.6.4.tgz
安装前做好相关依赖设置
否则可能会报错
zipimport.ZipImportError: can't decompress data; zlib not available
sudo apt-get install zlibc zlib1g-dev
编辑Modules/Setup文件
nano Modules/Setup
# 找到下面这句,去掉注释
#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
安装
cd Python-3.6.4
./configure --with-ssl
编译
sudo make
sudo make install
创建软连接,先查看python3.6.4的安装路径
which python3 # /usr/local/bin/python3
sudo ln -s /usr/local/bin/python3 python
网友评论