最近在开发一个项目时出现了错误,需要重新安装python和yum,怎么安装呢?随ytkah一起来看看吧。ytkah用的linux分支的centos7.6,各位朋友在下载源的时候要注意版本的区分。现在开始:

  1.1删除现有python

rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps  ##强制删除已安装程序及其关联
whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
whereis python ##验证删除,返回无结果

  1.2删除现有yum

rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
whereis yum |xargs rm -frv

  2.1然后到http://mirrors.ustc.edu.cn/centos/找到对应的centos版本下载相应的包,我的是centos7.6

wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/python-2.7.5-76.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/python-devel-2.7.5-76.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/python-libs-2.7.5-76.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/python-backports-1.0-8.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/python-ipaddress-1.0.16-2.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/python-chardet-2.2.1-1.el7_1.noarch.rpm wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/rpm-python-4.11.3-35.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/yum-utils-1.1.31-50.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-50.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/yum-plugin-aliases-1.1.31-50.el7.noarch.rpm

  2.2然后分别安装python和yum

rpm -Uvh --replacepkgs python*.rpm
rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm

  如果提示libxml2-python is needed by yum-utils-1.1.31-50.el7.noarch那么要先安装libxml2-python

wget http://mirrors.ustc.edu.cn/centos/7.6.1810/os/x86_64/Packages/libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm

  然后执行

rpm -Uvh --replacepkgs libxml2-python*.rpm

  3运行python进行测试,直接输入python

python
yum update

  

centos7.6删除重新安装python和yum的更多相关文章

  1. centos 卸载python和yum之后的解决办法

    网上看到有同学yum不能使用的消息,出现了下面的结果 无赖的使用了网上的很多方法,还是不行. 于是我卸载了python和yum,觉得自己重新安装python和yum. 步骤1:卸载python rpm ...

  2. CentOS7修复python拯救yum - 转载

    原文:http://blog.51cto.com/welcomeweb/2132654 本人正在吹着空调,喝着茶水,然后qq头像抖了两下,业务开发同学给我打了个招呼,“忙么?帮个忙可以不?” 这很明显 ...

  3. centos7误删除python2.7导致的python和yum不可用处理

    centos7误删除python2.7后导致yum不可用: 问题截图 解决方法: 1.在opt目录下创建site_package/python3递归目录,然后下载以下RPM包,并存入/opt/site ...

  4. Linux误删python导致yum不可用,删除重装方法。

    Linux 系统为 CentOS Linux release 7.4.1708 手贱.手贱.手贱 删了python 导致yum不可用.百度一大圈,重装yum和python后,老是报各种各样的错.历经磨 ...

  5. 解决删除/升级Python导致Ubuuntu无法进入桌面的问题

    找到问题的原因后于是换个思路,想大概修复了python,Ubuntu进入桌面应该也就没啥问题了.于是重新安装Python发现还是无济于事.也通过/usr/bin/python: can't find ...

  6. rpm重装python和yum

    前些天升级的python, yum就不能用了, 提示 "No module named yum", 然后搜索了一下, 说要重装python和yum, 也没多想, 就按照那些教程去做 ...

  7. 完全重装python和yum

    本文原链接 http://smilepad.blog.51cto.com/6094369/1333478 http://blog.etc168.com/?p=642 1.删除现有Python #roo ...

  8. Linux CentOs6.5误卸载自带python和yum后的解决办法

    事故背景:前几天因项目需要,在服务器上搭建python-mysql模块,结果没安装好,于是乎想卸载重装,遂在网上查询卸载python的方法,结果一不小心直接把系统的python删了个干净....... ...

  9. [转] 如何在 CentOS7 中使用阿里云的yum源

    [From] https://www.cnblogs.com/lpbottle/p/7875400.html 1. 备份原来的yum源 mv /etc/yum.repos.d/CentOS-Base. ...

随机推荐

  1. 负载均衡集群介绍 LVS介绍 LVS调度算法 LVS NAT模式搭建

    LVS BAT模式搭建 更改主机名: hostnamectl set-hostname centos7-three bash 准备工作 • 三台机器 • 分发器,也叫调度器(简写为dir) • 内网: ...

  2. MySQL主从介绍 准备工作 配置主 配置从 测试主从同步

    配置主: • 安装mysql • 修改my.cnf,增加server-id=130和log_bin=xiaobo1 • 添加环境变量 Vim /root/.bash_profile PATH=$PAT ...

  3. SpringMVC注解@RequestParam与RequestMapping全面解析

    1.@RequestParam用法: SpringMVC后台控制层获取参数的方式主要有两种, 一种是request.getParameter("name"), 另外一种是用注解@R ...

  4. linux环境中,多个命令之间,通过&& ||执行,命令之间执行的逻辑是什么?

    需求描述: 最近在写一个脚本的时候,要判断一个文件是否存在,有怎么样,没有就创建,这个时候 看到了一个test 结合 || 或者 &&的写法,就查看了下资料记录下是怎么个玩法. 操作过 ...

  5. [TensorBoard] Name & Variable scope

    TF有两个scope, 一个是name_scope一个是variable_scope 第一个程序: with tf.name_scope("hello") as name_scop ...

  6. [IR] Concept Search and LSI

    基于术语关系的贝叶斯网络信息检索模型扩展研究 LSI 阅读笔记 背景知识 提出一种改进的共现频率法,利用该方法挖掘了索引术语之间的相关关系,将这种相关关系引入信念网络模型,提出了一个具有两层术语节点的 ...

  7. Spring Boot 集成 Redis 实现缓存机制

    本文章牵涉到的技术点比较多:spring Data JPA.Redis.Spring MVC,Spirng Cache,所以在看这篇文章的时候,需要对以上这些技术点有一定的了解或者也可以先看看这篇文章 ...

  8. D - Football (aka Soccer)

    Football the most popular sport in the world (americans insist to call it "Soccer", but we ...

  9. Codeforces 758C-Unfair Poll

    Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  10. np.mgird np.ogrid

    np.ogrid: address:https://docs.scipy.org/doc/numpy/reference/generated/numpy.ogrid.html returns an o ...