1. Download Python-3.7.0.tgz
Reference website: https://www.python.org/downloads/
2. Upload and unzip Python-3.7.0.tgz
The version used here is 3.7.0, decompression needs to keep up with your own file name
tar xf Python-3.7.0
3. Install dependent packages
yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel libffi-devel gcc gcc-c++
The installation is successful as shown in the figure below
PS: If the installation is unsuccessful, you can consider changing the source (the following command is to install epel source)
yum -y install epel-release
4. Installation
cd
cd Python-3.7.0/
./configure --prefix=/usr/local/python
make && make install
cd /usr/local/python/bin/
Copy the following file to/usr/bin
cp python3 /usr/bin/
5. Test
6. Write a file for testing
vim hello.py
#!/usr/bin/python3
print("hello world")