Installation Environment: CentOS 7
Yum installation python3.4
In general, it is easy to use Python in Linux, since Linux has its own Python environment, and CentOS7 currently comes with python2.7. But it is said that python2.7 only support to 2020, from the study should be accustomed to the Python3 version of the use of the above method. Before you learn to configure the environment, first install the PYTHON3 environment. The simplest installation method is to install directly through Yum:
# Yum Search python//Check out the Python version supported by Yum Source # Yum Install python34//My Yum source supports up to python3.4
Yum is installed directly into the system by default and is installed by default to/usr/bin/. However, after the installation of Python display version or 2.7, this is because the multi-version of the/usr/bin/python is generally linked files, linked to the version of the file, such as the original executable file is/usr/bin/ python2.7, which is linked to python2.7 through Python, makes it possible to have both high and low versions without file conflicts. The Yum installation does not change its link target, so calling Python directly is equivalent to calling python2.7. So you need to manually change to link python3.4:
# cd/usr/bin/# RM python# ln-s python3.4 python
This way, when you execute Python, the version display is 3.4.
Source Installation python3.6.2
However, as a dead little expert, do not install the latest version how to do, usually the latest version rarely Yum can be installed, unless the version has stagnated for quite a long time. So the installation will need to use the source code to install.
Download https://www.python.org on the Python website
# wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz# yum install openssl-devel bzip2-devel expat-devel Gdbm-devel readline-devel sqlite-devel//install possible dependent libraries # TAR-ZXVF python-3.6.2.tgz# cd python-3.6.2/#./configure--prefix=/ usr/local///install to/usr/local directory # make# make Altinstall//This cannot be installed with install, because install does not differentiate version, there will be multiple version confusion problem
python3.6 program execution File:/usr/local/bin/python3.6 python3.6 application directory:/usr/local/lib/python3.6 pip3 execution File:/usr/local/bin/ pip3.6 pyenv3 execution File:/usr/local/bin/pyenv-3.6change the python default link
# cd/usr/bin# MV python python.backup# ln-s/usr/local/bin/python3.6/usr/bin/python# ln-s/usr/local/bin/ Python3.6/usr/bin/python3
High version of Yum dependency problem
After installing the high version Python there will be a very egg ache problem, yum is dependent on Python, after installing Python3, Yum will not be able to use directly, you need to specify to modify the Python script in Yum to use the interpreter.
Modify the header files for the/usr/bin/yum and/usr/bin/urlgrabber-ext-down two files, and change the first line #!/usr/bin/python to #!/usr/bin/python2
Linux installation python3.6.2