1. 备份原python
cd /usr/bin/
ls -al python*
mv python python2.7_start.bak
2. 下载python3
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0a1.tgz
tar -xvf Python-3.8.0a1.tgz
3. 安装python3
cd Python-3.8.0a1
./configure --prefix=/usr/local/python3
make
make install
Centos下安装python3.7.0以上版本时报错ModuleNotFoundError: No module named '_ctypes'解决方法
安装libffi-devel包
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libffi-devel-3.0.13-18.el7.x86_64.rpm
rpm -ivh libffi-devel-3.0.13-18.el7.x86_64.rpm
再返回原安装目录执行
make
make install
4. 创建软连接
cd /usr/bin
ln -s /usr/local/python3/bin/python3.8 /usr/bin/python
5. 修改yum的python支持(变为默认的2.7)
vim /usr/bin/yum
将#!/usr/bin/python改成#!/usr/bin/python2.7