python-3.8.2安装脚本
#!/bin/bash
#wget -P /tmp https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz &&
if [[ ! -d Python-3.8.2 ]];then
cp /tmp/Python-3.8.2 /usr/local/ -r
else
tar xvf /tmp/Python-3.8.2.tgz -C /tmp
cp /tmp/Python-3.8.2 /usr/local/ -r
fi
#创建此目录用于python3安装目录
if [[ ! -d /usr/local/python3 ]];then
mkdir /usr/local/python3
else
rm -rf /usr/local/python3
mkdir /usr/local/python3
fi
cd /usr/local/Python-3.8.2 &&
yum install gcc gcc-c++ zlib* -y || echo "安装依赖失败" &&
rm -rf /etc/yum.repos.d/*.repo &&
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo &&
yum makecache &&
yum install gcc gcc-c++ zlib* -y || echo "安装依赖失败" || exit
#编译安装,无任何报错表示安装完成
./configure --prefix=/usr/local/python3 && make && make install &&
ln -sv /usr/local/python3/bin/python3.8 /usr/bin/python3 &&
#加入环境变量
cat > /etc/profile.d/python3.sh << EOFF &&
export PATH=/usr/bin/python3:$PATH
EOFF
source /etc/profile.d/python3.sh
网友评论