centos7 重新安装python和yum亲测版本

it2024-07-08  40

centos7 重新安装python和yum亲测版本

前提: 主要是centos7本身带的python2.7不能安装requests模块(pip的版本太低,升级失败),但是还必须得用pythpn2.7,所以进行更改,但是还不能只重装python,因为yum和python是有关联的,一不注意yum可能就不好用了

1. 卸载python

rpm -qa|grep python|xargs rpm -e --allmatches --nodeps whereis python|xargs rm -fr

2. 卸载yum

rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps whereis yum|xargs rm -fr

3. 创建文件目录并下载rpm包

创建目录

mkdir /opt/python mkdir /opt/yum

下载安装包

cd /opt/python # python # 链接:https://pan.baidu.com/s/1MWnyXF-T6ACoNPB4pFBCDg # 提取码:7rgr cd /opt/yum # yum # 链接:https://pan.baidu.com/s/1r1_lYwp0ji9PrkKyIcHZmA # 提取码:cafs cd /opt # setuptools-25.0.0.tar.gz安装包 # 链接:https://pan.baidu.com/s/1Jo9HBkmnehlQBgKT4IVQGw # 提取码:8gm7 # pip-10.0.1.tar.gz安装包 # 链接:https://pan.baidu.com/s/1DgXI07uA9-Kzgt1Wt5Dbvg # 提取码:q4e0

4. 安装python

cd /opt/python rpm -ivh python-* rpm-* --nodeps --force

5. 安装yum

rpm -ivh yum-* --nodeps --force

此时python和yum就已经安装完成了,下面开始安装setuptools和pip 6. 安装setuptools和pip

安装setuptools

cd /opt tar zxvf setuptools-25.0.0.tar.gz cd setuptools-25.0.0 python setup.py build python setup.py install

安装pip

cd /opt tar zxvf pip-10.0.1.tar.gz cd pip-10.0.1 python setup.py build python setup.py install

7. 安装requests模块

pip install requests

这回成功了,谢谢大家的支持!!!!!!

最新回复(0)