centos7 安装python3.6
# 下载
wget https://www.python.org/ftp/python/3.7.5/Python-3.6.5.tgz
# 解压
tar -zxvf Python-3.6.5.tgz
# 进入目录
cd Python-3.6.5
# 安装配置
./configure
# 编译安装
make
make install
此处出现了错误:
zipimport.ZipImportError: can't decompress data;
zlib not available make: **
错误原因:缺少zlib依赖包
解决方法:
yum install zlib* -y
# 重新安装
make install
# 查看结果
python3 -V
# 设置python默认版本
ls -al /usr/bin | grep python
# 软连接重命名
mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/bin/python3 /usr/bin/python