1. 安装依赖关系
2. 下载和安装python包
cd /usr/local/src
wget https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz
tar zxvf Python-3.9.5.tgz
cd Python-3.9.5/
./configure --prefix=/usr/local/python3.9 --with-ssl
make && make install
3. 修改软连接
- ln -fs /usr/local/python3.9/bin/python3.9 /usr/bin/python
ln -fs /usr/local/python3.9/bin/python3.9 /usr/bin/python3
ln -fs /usr/local/python3.9/bin/pip3.9 /usr/bin/pip
ln -fs /usr/local/python3.9/bin/pip3.9 /usr/bin/pip3
5.修改yum文件
- vi /usr/bin/yum
vi /usr/libexec/urlgrabber-ext-down 第一行改都修改为: (原因是安装了python3.8,CentOS 7.X 自带的yum采用的是python2.X,当系统将python升级到2.7 或3.X后,出现语法解释错误) - #!/usr/bin/python2.7
6.升级pip
- python -m pip install --upgrade pip
出现错误必须:
ln -fs /usr/local/python3.9/bin/python3.9 /usr/bin/python
ln -fs /usr/local/python3.9/bin/python3.9 /usr/bin/python3
ln -fs /usr/local/python3.9/bin/pip3.9 /usr/bin/pip
ln -fs /usr/local/python3.9/bin/pip3.9 /usr/bin/pip3
必须