1.检查之前系统的python版本
[root@localhost ~]# python
Python 2.7.5 (default, Apr 2 2020, 13:16:51)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>>
>>>
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>>
[root@localhost ~]#
2.确保可以使用yum源进行升级
具体命令:
-
yum groupinstall ‘Development Tools’
-
yum install centos-release-scl
-
yum install rh-python36
-
python --version
python 2.7.5
-
scl enable rh-python36 bash
Python 3.6.3
-
yum -y install python-pip
[root@bogon ~]# python
Python 2.7.5 (default, Apr 2 2020, 13:16:51)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
KeyboardInterrupt
>>>
[root@bogon ~]# scl enable rh-python36 bash
[root@bogon ~]# python --version
Python 3.6.12
[root@bogon ~]# python
Python 3.6.12 (default, Oct 23 2020, 13:36:31)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
KeyboardInterrupt
>>>