preparatory work
Centos7 the Python2.7,yum command that is installed by default is python2.7.
python --versionCheck to see if Python is installed.
cd $(dirname `which python`)Enter the directory where the Python executable file is located
mv python python.bakBack up a bit
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc makeInstall related Packages
Yum If failure reference: http://www.cnblogs.com/juneman/p/8594633.html
Compiling the installation
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xzDownload the installation package
tar -xvJf Python-3.6.5.tar.xzExtract
cd Python-3.6.5Go to Catalog
./configure prefix=/usr/local/python3 make && make installCompiling the installation
After the installation is complete, the/usr/local/directory will appear Python3
ln -s /usr/local/python3/bin/python3 /usr/bin/pythonAdd a soft link to the execution directory
python --versionShow Python3 is successful
python2 --versionView Python2 Version Information
Because Yum needs to be python2, we also need to modify the Yum configuration: the vim /usr/bin/yum first line of the #! /usr/bin/python fix changed to#! /usr/bin/python2
Similarly, the vim /usr/libexec/urlgrabber-ext-down first line of #! /usr/bin/python revision changed to#! /usr/bin/python2
By doing this, Python2 is coexisting with Python3.
Linux-centos7 installing Python3 and coexistence with Python2