1. 安装编译相关软件
su
yum -y groupinstall "Development tools"
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
yum install libffi-devel -y
2.下载安装包解压
wget https://www.python.org/ftp/python/3.9.8/Python-3.9.8.tgz
tar -xvzf Python-3.9.8.tgz
3.编译安装
mkdir /usr/local/python3 #创建编译安装目录
cd Python-3.9.8
./configure --prefix=/usr/python3
make && make install
4.创建软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
5.验证是否成功
python3 -V
pip3 -V
中间遇到了一个问题,解决方案:
https://blog.csdn.net/y15713080686/article/details/130303697?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-130303697-blog-103903955.235%5Ev38%5Epc_relevant_sort&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-130303697-blog-103903955.235%5Ev38%5Epc_relevant_sort&utm_relevant_index=2