1. Environment
This article is based on installing Python3.6.2 in the Centos7 environment
Type in the terminal
#python
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
It can be seen that the system comes with Python 2.7.5 version, and it is a trend to use it with Python 3. Therefore, it is necessary to install Python 3. Since the operation of some system files depends on Python, it is not recommended to uninstall the system's built-in Python.
2. Install dependencies that may be used
3. Download the Python3.6.2 installation package
# wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
This action, for a minimal system installation or appears:
-bash:wget:command not found
That is, you need to manually install the wget package, through the yum command
#yum -y install wget
4. Unzip Python-3.6.2.tar.xz
Unzip the xz file first, then unzip the tar file.
# xz -d Python-3.6.2.tar.xz
# tar xvf Python-3.6.2.tar
# cd Python-3.6.2
# ./configure --prefix=/usr/local
This part of the operation, for the minimum system installation version, will appear:
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
The prompt system does not have a GCC compiler environment, so
# yum -y install gcc
# make & make altinstall
5. Change /usr/bin/Python link
#cd /usr/bin
#mv python python.backup //Backup python
#ln -s/usr/local/bin/python3.6 /usr/bin/python3 //Establish a soft link and execute it through Python3
6. Start Python3.6
#python3.6
Start Python3
#python2
Start Python2