安装yum及报错处理
安装yum的命令:
sudo apt install yum
若出现报错:
sudo: yum:找不到命令
解决方法:
- 切换到root用户:
sudo -s
或:
su:
- 执行以下命令:
sudo apt-get install build-essential
- 然后执行以下命令
sudo apt-get install yum
若出现以下报错:
正在读取软件包列表… 完成
正在分析软件包的依赖关系树
正在读取状态信息… 完成
E: 无法定位软件包 yum
则:
- 先备份以前的文件:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
- 在清华镜像中找到相应的文件:
找到对应的版本,本文中用的是Ubuntu20.04 - 打开list文件:
sudo gedit /etc/apt/sources.list
或者:
sudo vim /etc/apt/sources.list
- 将list文件中的内容全部删除,然后在第一行输入:
deb http://archive.ubuntu.com/ubuntu/ trusty main universe restricted multiverse
在此行后,将前面找到的清华镜像的内容复制在list文件中(此处为20.04版本):
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
得到list文件如下:
- 更新
sudo apt update
- 再次尝试下载:
sudo apt-get install yum
- 若还是出错,则执行下列命令:
sudo apt install python-urlgrabber
sudo apt install python-sqlitecachec
然后再次尝试下载yum
- 验证是否安装成功:
sudo yum version
参考文献:
【1】Ubuntu:yum命令找不到(包含报错解决方案)
【2】Ubuntu无法定位软件包yum(添加镜像后还出现)