centOS 源码安装python 3

一、查看当前Python版本

python -V

  

二、下载新的python包并安装

 

1、更新yum源

yum update

 

2、安装依赖项

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel gcc make
 
 
 3、下载python源码并编译安装
wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz
tar xvf Python-3.8.2.tgz 
cd Python-3.8.2
./configure --prefix=/usr/local/python3
make && make install

 

4、添加软连接

mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/python3/bin/python3 /usr/bin/python

 

这样系统的默认python版本都升级到python3咯

 

posted @ 2020-04-05 13:32  达叔叔  阅读(216)  评论(0编辑  收藏  举报