安装流程
[zhouhh@mainServer ~]$ cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)
[zhouhh@mainServer ~]$ sudo yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
[zhouhh@mainServer ~]$ wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
[zhouhh@mainServer ~]$ tar zxvf Python-3.6.0.tgz
[zhouhh@mainServer ~]$ cd Python-3.6.0/
[zhouhh@mainServer Python-3.6.0]$ ./configure --prefix=/usr/local --enable-optimizations
[zhouhh@mainServer Python-3.6.0]$ make
[zhouhh@mainServer Python-3.6.0]$ sudo make altinstall
[zhouhh@mainServer Python-3.6.0]$ cd /usr/local/bin
[zhouhh@mainServer bin]$ sudo rm idle3 2to3 pydoc3 python3 python3-config pyvenv
[zhouhh@mainServer bin]$ sudo ln -s 2to3-3.6 2to3
[zhouhh@mainServer bin]$ sudo ln -s idle3.6 idle3
[zhouhh@mainServer bin]$ sudo ln -s pydoc3.6 pydoc3
[zhouhh@mainServer bin]$ sudo ln -s python3.6 python3
[zhouhh@mainServer bin]$ sudo ln -s python3.6m-config python3.6-config
[zhouhh@mainServer bin]$ sudo ln -s python3.6-config python3-config
[zhouhh@mainServer bin]$ sudo ln -s pyvenv-3.6 pyvenv3
也可以考虑将python缺省值替换到python3,但相关yum 调用也需要修改。
[zhouhh@mainServer bin]$ ls -l python*
lrwxrwxrwx. 1 root root 7 Oct 26 2016 python -> python2
lrwxrwxrwx. 1 root root 9 Oct 26 2016 python2 -> python2.7
-rwxr-xr-x. 1 root root 7136 Jun 18 2014 python2.7
[zhouhh@mainServer bin]$ python3
Python 3.6.0 (default, Apr 27 2017, 14:53:11)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()