1、安装所需依赖

[root@node02 ~]# yum -y install wget gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel

2、下载Python3.8.1

[root@node02 ~]# wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz

3、设置语言

[root@node02 ~]# echo "LANG=zh_CN.UTF-8" >> /etc/profile
[root@node02 ~]# echo "LANGUAGE=zh_CN.UTF-8" >> /etc/profile
[root@node02 ~]# . /etc/profile

4、解包并编译安装

[root@node02 ~]# tar zxf Python-3.8.1.tgz -C /usr/src
[root@node02 ~]# cd /usr/src/Python-3.8.1/
[root@node02 Python-3.8.1]# ./configure --prefix=/usr/local/python38 --enable-optimizations && make && make install

5、配置环境变量

[root@node02 Python-3.8.1]# echo "PATH=$PATH:/usr/local/python38/bin" >> /etc/profile
[root@node02 Python-3.8.1]# . /etc/profile

6、查看python的版本

[root@node02 Python-3.8.1]# python3 --version
Python 3.8.1

———————— 本文至此结束,感谢阅读 ————————