CentOS升级Python2到Python3
centos 的系统默认是使用python2进行管理和yum升级 所以要把原来的指定到python2
[root@VM_0_4_centos ~]# vim /usr/bin/yum [root@VM_0_4_centos ~]# vim /usr/libexec/urlgrabber-ext-down
#!/usr/bin/python2.7
注意不能改成python2 要改成python2.7
可以简单看下Python的环境
[root@VM_0_4_centos ~]# whereis python python: /usr/bin/python /usr/bin/python2.7-config /usr/bin/python2.7 /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /usr/share/man/man1/python.1.gz [root@VM_0_4_centos ~]# ls -alh /usr/bin/python lrwxrwxrwx 1 root root 7 Jun 22 17:14 /usr/bin/python -> python2 [root@VM_0_4_centos ~]# whereis python2 python2: /usr/bin/python2 /usr/bin/python2.7-config /usr/bin/python2.7 /usr/lib/python2.7 /usr/lib64/python2.7 /usr/include/python2.7 /usr/share/man/man1/python2.1.gz [root@VM_0_4_centos ~]#
把上面两个文件的python 改成python2以后 就可以安装python3了
目前默认yum源是 python36 如果要安装3.7 需要下载源码包了 这里就省事了 毕竟不就结这个具体的版本
yum install -y python36
yum install -y python36-setuptools
yum install -y python36-pip
设置成默认的python
[root@VM_0_4_centos bin]# ln -s /usr/bin/python3.6 /usr/bin/python [root@VM_0_4_centos bin]# python Python 3.6.8 (default, Apr 2 2020, 13:34:55) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux Type "help", "copyright", "credits" or "license" for more information. >>>
没啥技术含量,但是我这脑子总是记不住,今天说不能再这样了,不能在一个坑里一直跌到啊。