The CentOS 7 system comes with Python2, but you can run the Python script directly with Python3 without the 2 version, but do not move the system's own Python2, because the program relies on the current python2 environment, such as Yum, Yum will not work, and other programs may be affected. Understand the above, and then come to install the Python3.6:
Installation steps:
1. Install dependent environment
# yum-y Install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-de Vel libpcap-devel xz-devel
2. Download Python3
https://www.python.org/downloads/
1 |
# wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz |
3. Installing Python3
Package installed in/usr/local/python3 (specific installation location to see a person's preferences)
To create a directory:
1 |
# mkdir -p /usr/local/Python3 |
Unzip the downloaded PYTHON-3.6.5.TGZ package (specific package name because you download the specific version of Python, I downloaded the Python3.6.5 here to take python-3.6.5.tgz as an example)
1 |
# tar -zxvf Python-3.6.5.tgz |
4. Enter the extracted directory, compile and install
If the compilation of the installation process has an error message to see my other essay written solution http://www.cnblogs.com/shwee/p/9013851.html
12 |
# cd Python-3.6.5 # ./configure --prefix=/usr/local/Python3 |
Then: Make
Next: Make Install
Or two-step together: Make && make install
5. Set up the Python3 soft chain
1 |
# ln -s /usr/local/Python3/bin/python3 /usr/bin/python3 |
6. And add/usr/local/python3/bin to path
123456789 |
# vim ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if
[
-
f ~
/
.bashrc ]; then
. ~
/
.bashrc
fi
# User specific environment and startup programs
PATH
=
$PATH:$HOME
/
bin
:
/
usr
/
local
/P
ython3
/
bin
export PATH
|
Press ESC, enter: Wq, press ENTER to save exit edit.
After the modification, remember to execute the following line command to make the previous modification effective:
1 |
# source ~/.bash_profile |
Check if Python3 and PIP3 are normally available:
1234 |
# python3 -V
Python
3.6
.5
# pip3 -V
pip
9.0
.3 from
/
usr
/
local
/P
ython3
/
lib
/
python3.
6
/
site
-
packages (python
3.6
)
|
Hong Wei
Source: http://www.cnblogs.com/shwee/
CentOS 7 Installation Python3.6 process (let Linux systems coexist Python2 and PYTHON3 environments)