Although Ubuntu18.04LTS has built-in support for python3.6, but sometimes CentOS7 is still used, let's summarize how to install python3.6 under CentOS7
1. Preparation before installing python
In order to reduce errors in the future, first download the required software below
yum install zlib* openssl* yum install gcc yum install sqlite-devel
Create a python3 folder and enter the folder
mkdir /usr/local/python3 cd /usr/local/python3
Download the source code of python3
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
Unzip the python3 source code
tar -zxvf Python-3.6.5.tgz
2. Compile python3
Go to the python3 source folder and precompile
cd Python-3.6.5 ./configure --prefix=/usr/local/python3/python3 --enable-optimizations
Compile (takes a long time)
make
Installation (also takes longer)
make install
3. Configure system environment variables
Open configuration file
vi ~/.bashrc
Add a line after the end PATH=$PATH:/usr/local/python3/python3/bin
and execute after saving and exiting
source ~/.bashrc
This is done!
python3
Start using python3 by typing in the command line