WSL安装yum报错:E: Unable to locate package yum

一 问题

想要在WSL里面安装yum

执行命令

sudo apt-get install yum

报错如下

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package yum

报错信息精华是:E: Unable to locate package yum(E:无法找到包yum)

二 解决方案

1.尝试了网上提供的解决方案,执行如下代码,无法解决。

其中apt-get和apt的区别是:在基于 Debian 的 Linux 发行版中,Linux 包管理命令都被分散在了 apt-get、apt-cache 和 apt-config 这三条命令当中。apt 命令的引入就是为了解决命令过于分散的问题,它包括了 apt-get 命令出现以来使用最广泛的功能选项,以及 apt-cache 和 apt-config 命令中很少用到的功能,在使用 apt 命令时,用户不必再由 apt-get 转到 apt-cache 或 apt-config,而且 apt 更加结构化,并为用户提供了管理软件包所需的必要选项。

apt update
apt-get update
apt-get upgrade

2.考虑到报错信息提示无法找到包yum,尝试着修改镜像下载地址

输入如下命令,查看当前系统信息

lsb_release -c

WSL有个/etc/apt/sources.list,维护着下载软件的源地址,输入以下命令进入sources.list文件

sudo edit /etc/apt/sources.list

 在首行添加镜像地址如下

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security multiverse 

按esc,输入:!wq退出后,执行如下命令。对软件源列表进行更新

apt-get update

更新后,重新执行如下命令,安装成功

sudo apt-get install yum

三 在WSL下载yum命令后

1.输入一下命令,本来要检测是否安装yum成功。但是WSL终端窗口没有反应

rpm -qa | grep yum

原因是Ubuntu不支持rpm和yum包管理系统。

对于这个问题,官方说法如下

Do not install rpm in Debian (I don't mean flash-plugin, I mean rpm package management). Debian's package management system (which makes sure everything is installed properly and with no conflicts.) is dpkg and it also includes apt-get, Synaptic and aptitude that use dpkg. RPM will bypass dpkg, so you may cause serious damage to your system.

If you need to install an rpm package, you must do it using the tool "alien". It converts RPM packages to .deb and installs them properly through dpkg.

不要在Debian中安装rpm(我不是说闪存插件,我是指rpm软件包管理)。 Debian的软件包管理系统(可确保一切安装正确且没有冲突。)是dpkg,它还包括使用dpkg的apt-get,Synaptic和aptitude。 RPM将绕过dpkg,因此可能会严重损坏系统。 如果需要安装rpm软件包,则必须使用工具“ alien”进行安装。 它将RPM软件包转换为.deb并通过dpkg正确安装。)

2.是用alien将rpm包转化为deb包。Alien是一个将rpm, dpkg, stampede slp及slackware tgz档案格式间转换的工具

首先安装alien

apt-get install alien

使用alien将rpm包转换成.deb格式的包

alien package.rpm

执行完成后生成一个.deb的软件包,再通过dpkg安装.deb格式的包

dpkg -i package.deb
原文地址:https://www.cnblogs.com/aczy/p/14300384.html