yum -y groupinstall "Development tools"
yum -y install zlib zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum -y install libffi-devel
mkdir /usr/local/python3
cd /usr/local/python3
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
tar xf Python-3.9.0.tgz
cd /usr/local/python3/Python-3.9.0
./configure prefix=/usr/local/python3 --with-ensurepip=install
make -j 4 && make install
mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/python3/bin/python3.9 /usr/bin/python
python -V
vim /usr/bin/yum
原:#!/usr/bin/python 改:#!/usr/bin/python2
vim /usr/libexec/urlgrabber-ext-down
原:#! /usr/bin/python 改:#! /usr/bin/python2
python2
python
#!/bin/bash
echo -e "\033[32m安装开发库,wait......\033[0m"
yum -y groupinstall "Development tools" &> /dev/null
echo ' '
echo -e "\033[32m安装依赖环境,wait......\033[0m"
yum -y install zlib zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel wget &> /dev/null
echo ' '
echo -e "\033[32m安装 libffi-devel,wait......\033[0m"
yum -y install libffi-devel &> /dev/null
echo ' '
mkdir -p /usr/local/python3
echo -e "\033[32m下载 python3.9.0 源码包,wait......\033[0m"
wget http://101.34.22.188/python/Python-3.9.0.tgz -P /usr/local/python3 &> /dev/null
echo ' '
echo -e "\033[32m解压源码包,wait......\033[0m"
tar xf /usr/local/python3/Python-3.9.0.tgz -C /usr/local/python3 &> /dev/null
echo ' '
echo -e "\033[32m编译安装,wait......\033[0m"
cd /usr/local/python3/Python-3.9.0
./configure prefix=/usr/local/python3 --with-ensurepip=install &> /dev/null
sleep 5
make &> /dev/null
make install &> /dev/null
sleep 5
echo ' '
echo -e "\033[32m创建软连接,wait......\033[0m"
mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/python3/bin/python3.9 /usr/bin/python
echo ' '
echo -e "\033[32m更改 yum 脚本的 python 依赖,wait......\033[0m"
sed -i 's/\#\!\/usr\/bin\/python/\#\!\/usr\/bin\/python2/' /usr/bin/yum
sed -i 's/\#\! \/usr\/bin\/python/\#\! \/usr\/bin\/python2/' /usr/libexec/urlgrabber-ext-down
echo ' '
echo -e "\033[33mPython3.9.0 安装成功\033[0m"
echo -e "\033[32mPython3:python\033[0m"
echo -e "\033[32mPython2:python2\033[0m"
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。