1.安装依赖环境
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
2.下载python3
wget -P /opt https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz
3.安装python3
1.创建安装目录
mkdir -p /usr/local/python3
2.解压
cd /opt
tar -zxvf Python-3.10.0.tgz
3.安装编译器及依赖包(3.7版本之后需要一个新的包libffi-devel)
yum install gcc -y
yum install libffi-devel -y
4.指定模块
cd Python-3.7.1
./configure --prefix=/usr/local/python3
5.编译及安装
make -j 4 & make install
6.检查python3.7的编译器
/usr/local/python3/bin/python3.7
4.建立python3和pip3的软链
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
5.检查Python3及pip3是否正常可用
[root@c7-4 Python-3.10.0]
Python 3.10.0
[root@c7-4 Python-3.10.0]
pip 21.2.3 from /usr/local/python3/lib/python3.10/site-packages/pip (python 3.10)