下载Python3包:
wget https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tgz
安装依赖:
yum -y install zlib-devel libffi-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
解压,编译,安装:
tar -xvzf Python-3.8.3.tgz
cd Python-3.8.3
./configure --prefix=/usr/local/python3
make
make install
添加Python3环境变量:
vi /etc/profile
在以下位置添加:
PATH=$PATH:/usr/local/python3/bin
保存退出,执行:source /etc/profile
python3 -V
python -V
这里不建议把系统默认Python2版本替换为Python3,所有基于Python2的组件会异常,虽然可以修改配置文件,但你得一个个去修改,比较麻烦