寫在前面
centos6.8中預設自帶的python版本為python2.6,那麼這裡需要將其改為python3
下載並解壓
官方下載地址為 https://www.python.org/downlo… ,這裡已3.6.3為例。
# 下載
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
# 解壓
tar -zxvf Python-3.6.3.tgz
cd Python-3.6.3
安裝
[root@localhost ~]# ./configure prefix=/usr/local/python3 --enable-optimizations
[root@localhost ~]# make && make install
修改python3為預設的python
[root@localhost ~]# which python
/usr/bin/python
[root@localhost ~]# mv /usr/bin/python /usr/bin/python.bak
/usr/bin/python
[root@localhost ~]# ln -s /usr/local/python3/bin/python3 /usr/bin/python
python3和python2共存
[root@localhost ~]# python -V
Python 3.6.3
[root@localhost ~]# python2.6 -V
Python 2.6.6
由於yum用的python仍然是2.6,所以這裡修改一下
[root@localhost ~]# vim /usr/bin/yum
將第一行改為:
#!/usr/bin/python2.6