Install Python3.5 on Centos7
Centos7 is installed with python2.7.5 by default. For example, yum uses python2.7.51 to download the package of python3.5.
Https://www.python.org/downloads/release/python-351/ at python Official Website
Download the tgz package. In fact, either of the following two packages can be used.
Python-3.5.1.tgz (this is not compiled, can not be decompressed directly use)
Python-3.5.1.tar.xz (this is pthon source code)
2-decompress the file
tar -xf Python-3.5.1.tgz
3-decompress the package and enter the Python-3.5.1 directory.
cd Python-3.5.1
4-start installation and use the compilation method for Installation
There is a README file in the python Directory, which describes how to install python. However, we need to specify the installation directory.
mkdir /usr/python3.5./configure --prefix=/usr/python3.5makemake install
Note: After the/configure command is executed, create a file creating Makefile for the following make command to install the program in the specified directory after running make install.
5-use Python 3.5.1 by default
Python, python2, and python2.7 files in/usr/bin point to the latter in sequence.
cd /usr/bin mv python python.bak ln -s /usr/python3.5/bin/python3 /usr/bin/python
Note that after compilation and installation, a python3 connection is automatically generated under/usr/python3.5/bin, which points to python3.5 in the bin directory.
6-Because yum uses python2, replacing it with python3 may not work properly. continue to use this python2.7.5
Therefore, modify the yum configuration file (sudo vi/usr/bin/yum ). #! /Usr/bin/python #! /Usr/bin/python2.7 save and exit.