- 官网下载安装包,使用wget命令
- 下载必要的编译依赖包
yum install -y gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-deve
- 解压依赖包,注意版本号
tar -zxvf Python.tgz
- 进入目录,查看configure文件权限,若无执行权限,chmod 777 configure
ls -alh
sudo chmod 777 configure
./configure --prefix=安装目录
make
make test
sudo make install
- 永久将安装目录的路径添加到PATH中,
vim /etc/profile
在最后添加上export PATH=$PATH:安装目录
,wq保存退出后,执行source /etc/profile
- 将python3设为默认python
cd /usr/bin
;rm python
;ln -s python3 python