System environment :centos 7.6
Python edition :Python-3.6.8
Python3.x The installation of depends on these four components :gcc, zlib,zlib-devel,openssl-devel; So it needs to be pre installed , The order is as follows :
yum install gcc -y
yum install zlib -y
yum install zlib-devel -y
yum install openssl-devel -y
Python Source package download address : https://www.python.org/downloads/
# wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
# tar -zxvf Python-3.6.8.tgz
Enter the root directory to compile , You can specify the path to compile and install , Here we designate as /usr/app/python3.6
:
# cd Python-3.6.8
# ./configure --prefix=/usr/app/python3.6
# make && make install
vim /etc/profile
export PYTHON_HOME=/usr/app/python3.6
export PATH=${PYTHON_HOME}/bin:$PATH
Make the configured environment variables take effect immediately :
source /etc/profile
Input python3
command , If you can get into python Interactive environment , The installation is successful :
[[email protected] app]# python3
Python 3.6.8 (default, Mar 29 2019, 10:17:41)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1+1
2
>>> exit()
[[email protected] app]#