1.安装第三方库
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
yum install libffi-devel -y
2.安装python3.8.2
#建立新目录
sudo mkdir /usr/local/python3
#下载3.8.2
wget --no-check-certificate https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz
#解压安装包,编译安装
tar xzvf Python-3.8.2.tgz
cd Python-3.8.2
sudo ./conigure --prefix=/usr/local/python3
sudo make && sudo make install
#创建软链接
sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python3
#验证python安装 python3 -V
3.安装pip
#通过get-pip.py安装
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
#创建软链接
sudo ln -s /usr/local/python3/bin/pip /usr/bin/pip3
#验证安装
pip3 -V
这样保留原系统的python2.7,不会造成系统异常。
来源:oschina
链接:https://my.oschina.net/leboo/blog/3211437