Although the ubuntu18.04lts built-in support python3.6, but sometimes will use CentOS7, to summarize how to install python3.61 under CentOS7. Preparing for Python before installing
-
To reduce future errors, download the required software below
yum install zlib* openssl*yum install gccyum install sqlite-devel
-
Create a Python3 folder and go to the folder
mkdir /usr/local/python3cd /usr/local/python3
-
Download the source code for Python3
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
-
Decompression Python3 Source code
tar -zxvf Python-3.6.5.tgz
2. Compiling Python3
-
Enter 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 a longer time)
make install
3. Configuring System Environment variables
Open configuration file
vi ~/.bashrc
Add a row after the lastPATH=$PATH:/usr/local/python3/python3/bin
Save after exiting execution
source ~/.bashrc
That's it!
Start using Python3 at the command line input python3 .
How to install the python3.6 under CentOS7