CentOS 7 system upgrade to the latest version 2.7.5 comes with Python Python 3.7.2

CentOS 7 in the default installation of Python 2.7.5 version, due Python2 and Python3 great differences, so some applications compatible Python3 but incompatible Python2, it is necessary to upgrade our own Python2 to Python3. But many basic commands, packages are dependent on older versions, such as: yum. Therefore, when you update Python, we recommended not to delete the old version (old and new versions can coexist).

First, view the current python version

python -V
# centos 7默认内置Python 2.7.5

Second, download and install the new package python

Into the python's official website ( https://www.python.org ), select the desired version. Here I chose the most current version of Python 3.8.2. Select the same principle to other versions, just below the code section 3.8.2 version you want to replace, such as 3.6.1 etc.

#下载
wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz
# 在这里我提供一个镜像站点
wget http://207.246.90.165/Python-3.8.2.tar.xz
# 解压缩
tar xvf Python-3.8.2.tar.xz
# 安装必备依赖
yum install -y libffi-devel
# 进入解压目录
cd Python-3.8.2/
# 编译
./configure
# 安装
make && make install 

Third, verify

python -V     #查看Python2的版本号
python3 -V    #查看Python3的版本号

It can be used when needed later Python3 python3 + commands, such as: python3 /s.py the like; command may be used python + python2. Similarly, the corresponding pip, also similar.

Guess you like

Origin www.cnblogs.com/nickwu/p/12601108.html