最新的CentOS8已经内置了Python2和Python3,出入Python2和Python3两个命令可以分别进入Python2和Python3。
CentOS中安装python3.8.2_centos
CentOS8内置的Python3版本为3.6.8,我们需要将它升级到3.8.2



首先下载Python3.8.2的安装包


wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz


CentOS中安装python3.8.2_centos_02

下载好安装包后,下载python3.8所需要的环境依赖包


yum install gcc openssl-devel bzip2-devel libffi-devel


CentOS中安装python3.8.2_python_03

解压缩Python3.8.2.tgz


tar zxf Python3.8.2.tgz


ls命令Python3.8.2的·文件夹

cd命令进入Python3.8.2文件夹


cd Python3…8.2/


CentOS中安装python3.8.2_linux_04

安装Python3.8.2


./configure --enable-optimizations
make altinstall


CentOS中安装python3.8.2_安装包_05

CentOS中安装python3.8.2_python_06

安装完毕后,进入python的解释器


python3.8


CentOS中安装python3.8.2_centos_07

安装python3.8.2并不会覆盖CentOS内置的python3.6.8,使用命令python3仍然可以进入3.6.8版本,必须使用命令python3.8才能进入3.8.2版本

CentOS中安装python3.8.2_安装包_08