更新Python版本

①创建下载目录

[root@VM-8-15-centos Downloads]# cd /root
[root@VM-8-15-centos ~]# mkdir Downloads
[root@VM-8-15-centos ~]# cd /root/Downloads/
[root@VM-8-15-centos Downloads]# mkdir software

更新Python版本_第1张图片

②下载到当前目录

#python 3.8.5版本
[root@VM-8-15-centos software]# wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz

#python 3.10.0版本
[root@VM-8-15-centos software]# wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz

③解压

[root@VM-8-15-centos software]# tar -xvf Python-3.8.5.tgz

# 进入该目录
[root@VM-8-15-centos software]# cd Python-3.8.5/

# 修改配置文件  --prefix:设定安装目录
[root@VM-8-15-centos software]# ./configure --prefix=/root/Downloads/software/Python-3.8.5   
[root@VM-8-15-centos software]# make
[root@VM-8-15-centos software]# make install  

④设置软链接

[root@VM-8-15-centos software]# mv /usr/bin/python /usr/bin/python2.7.bak   #备份原链接
[root@VM-8-15-centos software]# ln -s /root/Downloads/software/Python-3.8.5/bin/python3 /usr/bin/python  #设置新链接

⑤查看版本

[root@VM-8-15-centos software]# python --version

你可能感兴趣的:(CentOS,python,linux,运维)