Take Centos7 as an example:
Source installation python, usually first install some devel package:
Yum-y install XZ wget gcc make gdbm-devel openssl-devel sqlite-devel zlib-devel bzip2-devel
Then download the source code
Decompression Source:
TAR-JXF PYTHON.X.TAR.XZ
CD pyhton.x
./configure
Here are some options,--Bindir: The path where which Python is located after installation is complete
--prefix refers to the prefix of the path where Python is installed, such as: not Specified is/usr/local
When finished, generate the makefile file if direct./configure,python will be installed in
/usr/local/lib/python27 under
But what if I want to install it on any path?
Makefile has the following line, modify this can be
Libdest= $ (Scriptdir)/python$ (VERSION)
There is no time to overwrite the python that is installed with the operating system, because some of the infrastructure uses Python, for example: Yum