centos7 安装python3
1、安装依赖
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc libffi-devel python-devel -y
2、下载python包
wget https://www.python.org/ftp/python/3.9.16/Python-3.9.16.tgz
3、解压、编译
tar xf Python-3.9.16.tgz && cd Python-3.9.16 ./configure --prefix=/usr/local/python3.9.16 make -j `grep processor /proc/cpuinfo | wc -l` && make install
4、验证新版本python
# 添加软连接,方便升级
ln -s /usr/local/python3.9.16 /usr/local/python
# 添加环境变量
echo "export PATH=$PATH:/usr/local/python/bin" >> /etc/profile && source /etc/profile
[root@zabbix-server local]# python3 -V Python 3.9.16