CentOs下安装python3并设为默认python

1、安装python3

[root@localhost ~]# wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
[root@localhost ~]# tar -xvJf  Python-3.6.4.tar.xz
[root@localhost ~]# cd Python-3.6.4/
[root@localhost Python-3.6.4]# ./configure prefix=/usr/local/python3
[root@localhost Python-3.6.4]# make && make install

2、建立软连接

[root@localhost Python-3.6.4]# ln -s /usr/local/python3/bin/python3 /usr/bin/python
[root@localhost bin]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip

3、修改常用软件对python2的依赖

  • yum
[root@localhost bin]# vim /usr/bin/yum
# 把#!/usr/bin/python 修改为 #!/usr/bin/python2
  • supervisor
修改 /usr/bin/supervisord /usr/bin/echo_supervisord_conf /usr/bin/supervisorctl
 #!/usr/bin/python 改成 #!/usr/bin/python2
04-25 00:45