CentOS 升级安装Python2.7.X
第一步:查看Centos版本及python版本
Centos版本
[root@k8s-admin-lb ~]# cat /etc/centos-release
CentOS Linux release 7.7.1908 (Core)Python版本
[root@k8s-admin-lb ~]# python -V
Python 2.7.5
[root@k8s-admin-lb ~]# which python
/usr/bin/python
[root@k8s-admin-lb ~]# ll -l /usr/bin/python*
lrwxrwxrwx. 1 root root 7 Oct 8 17:14 /usr/bin/python -> python2
lrwxrwxrwx. 1 root root 9 Oct 8 17:14 /usr/bin/python2 -> python2.7
-rwxr-xr-x. 1 root root 7216 Aug 7 08:52 /usr/bin/python2.7
-rwxr-xr-x 1 root root 1835 Aug 7 08:51 /usr/bin/python2.7-config
lrwxrwxrwx 1 root root 16 Oct 8 17:20 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root 14 Oct 8 17:20 /usr/bin/python-config -> python2-config第二步:从官网下载python对应版本的包(以2.7.9版本为例)
第三步:解压、配置、编译、安装python2.7.9
安装gcc(在编译时会依赖)
配置、编译、安装
第四步:安装后环境检查
python安装后的版本
安装前后的python对比
备份旧版本,连接新版本
再次检查python版本
若想访问老版本python(如2.7.5版本)
其他python访问,比如python2、python2.7
第五步:设置yum(系统预装的yum引用的老版本python)
更改设置
测试yum是否可用
最后更新于
这有帮助吗?