使用Linux安装yum报错 E: Unable to correct problems, you have held broken packages.

**【写在最前面】**作为Linux初学者,在一位很nice的朋友F君建议下从Win11Microsoft store下载了Ubuntu 20.04.5 LTS和window terminal,并且教了我很多非常实用的方法,非常感谢他!另外,作为初学者,文中不免存在错误或者缺失,如有偏误,烦请大家多多指正,感恩~

问题描述

本人装了Ubuntu 20.04.5 LTS,在安装yum过程中执行命令:

sudo apt install yum

但是发生如下错误:

E: Unable to locate package yum

截图长这样:
报错示例一
然后搜索了解决办法,需要更新镜像源,开始了多次尝试,本文旨在记录本人在解决问题过程中遇到的bug或者是自己马虎犯的错,下文略显冗长,烦请担待

解决步骤

1.修改source.list

依次执行下面两句命令

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #修改之前记得备份
sudo vim /etc/apt/sources.list #修改

到这里会进入vim编辑器,把我前前后后修改的source.list粘贴在下面仅供参考

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted


## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu/ focal  universe
deb-src http://mirrors.aliyun.com/ubuntu/ focal  universe
deb http://mirrors.aliyun.com/ubuntu/ focal-updates  universe
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates  universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.aliyun.com/ubuntu/ focal multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal multiverse

#添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

#中科大源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

#163源
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse

#清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

vim编辑时的步骤如下:

1.  按 i,发现vim最下面变成INSERT,就是可编辑的状态了 
2.  粘贴镜像源/或者手动输出
3.  按Esc,退出编辑,INSERT消失,就是退出编辑状态了
4.  控制游标到最后面,输入 :wq!  
5.  然后回车,便完成vim编辑

【NOTES】这里是一段血的教训/(ㄒoㄒ)/~~
在编辑vim时因为加班比较晚头晕眼花,好几个地方输入错误,报了各种各样的错误,白白浪费时间找编辑错的地方,所以我把我的镜像源贴在上面,有需要的朋友可以直接粘贴使用,节省时间

然后执行下面一句命令

sudo apt-get update #更新列表

2.安装yum

重新执行yum安装命令

sudo apt install yum

本来以为到这里该成功了,然后又报了另一个错误(⊙﹏⊙∥)

E: Unable to correct problems, you have held broken packages.

但是查了下这里的意思是没有依赖的包,那就是依次安装这些包就行了,突然冷静下来✿◡‿◡
截图大概长下面这个样子
报错示例二
然后依次执行下面的命令

sudo apt-get install python-lzma
sudo apt-get install python-sqlitecachec
sudo apt-get install python-urlgrabber

安装完毕后再次执行yum安装命令

sudo apt install yum

来看看yum是不是安装好了

yum --version #查看yum版本

输出如下:
安装成功
成功安装!撒花撒花★,°:.☆( ̄▽ ̄)/$:.°★

总结

几天时间的摸索,参考了很多大神的博客,链接贴在下面,有需要的朋友可以转到大神们的博客学习。自己也逐渐学会看报错原因,找问题出在哪里,但是中间因为马虎导致浪费了很多时间就大可不必o_o …,希望除了学习到一些技术知识还能改掉一些坏习惯,与诸君共勉

参考链接

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值