python2升级python3
查看当前版本
[root@test-01 node-v18.16.0]# python -V
Python 2.7.5
安装依赖
[root@test-01 node-v18.16.0]# yum install -y gcc gcc-c++ zlib zlib-devel readline-devel
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* centos-sclo-rh: mirrors.ustc.edu.cn
* centos-sclo-sclo: mirrors.ustc.edu.cn
* extras: mirrors.ustc.edu.cn
* updates: mirrors.ustc.edu.cn
软件包 gcc-4.8.5-44.el7.x86_64 已安装并且是最新版本
软件包 gcc-c++-4.8.5-44.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
安装python
[root@test-01 node-v18.16.0]# yum install python3
配置python3
[root@test-01 node-v18.16.0]# python --version
Python 2.7.5
[root@test-01 node-v18.16.0]# python3 --version
Python 3.6.8
[root@test-01 node-v18.16.0]# vim /usr/bin/^C
[root@test-01 node-v18.16.0]# alternatives --install /usr/bin/python python /usr/bin/python3 10
[root@test-01 node-v18.16.0]# python --version
Python 3.6.8
[root@test-01 node-v18.16.0]# alternatives --set python /usr/bin/python3
[root@test-01 node-v18.16.0]# python --version
Python 3.6.8