安装编译相关工具
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
下载并解压python安装包
wget https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tgz
tar -zxvf Python-3.8.3.tgz -C /usr/local/
编译安装python
mkdir /usr/local/python3
cd /usr/local/Python-3.8.3
./configure --prefix=/usr/local/python3
make && make install
创建软连接
# 查看当前python软连接 默认系统安装的是python2.7
ll /usr/bin/ |grep python
#删除python软连接
rm -rf /usr/bin/python
#添加python3的软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python
#查看版本
python -V
#删除默认pip软连接
rm -rf /usr/bin/pip
#添加 pip3 的软链接
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
更改yum配置
vim /usr/bin/yum
vim /usr/libexec/urlgrabber-ext-down
vim /usr/bin/yum-config-manager
把 #! /usr/bin/python 修改为 #! /usr/bin/python2
上次更新时间 13 3 月, 2023 at 09:59 上午