无法在 Ubuntu 18.04 上安装 libsnmp-dev(软件包依赖性错误)

无法在 Ubuntu 18.04 上安装 libsnmp-dev(软件包依赖性错误)

请帮忙!当我执行此命令时:

sudo apt-get install libsnmp-dev

我收到此错误:

~$ sudo apt-get install libsnmp-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libsnmp-dev : Depends: libpci-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

当我做:

sudo apt-get install libpci-dev

我得到:

~$ sudo apt-get install libpci-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libpci-dev : Depends: libudev-dev (>= 196) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

当我做:

sudo apt-get install libudev-dev

我得到:

~$ sudo apt-get install libudev-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libudev-dev : Depends: libudev1 (= 237-3ubuntu10) but 237-3ubuntu10.3 is to be installed
E: Unable to correct problems, you have held broken packages.

当我做:

sudo apt-get install libudev1

我得到:

~$ sudo apt-get install libudev1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libudev1 is already the newest version (237-3ubuntu10.3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

我尝试了针对此类问题的所有常见修复方法,这些方法在本页进行了很好的总结:

http://sourcedigit.com/21301-fix-broken-packages-ubuntu-terminal-list-broken-packages-ubuntu/

如果链接中断,我会将其复制/粘贴到这里:

sudo dpkg --remove -force --force-remove-reinstreq libsnmp-dev

sudo dpkg --remove -force --force-remove-reinstreq libpci-dev

sudo dpkg --remove -force --force-remove-reinstreq libudev-dev

命令 1

sudo apt-get --fix-broken install

命令 2

如果 Ubuntu 软件包安装失败(由于依赖关系),请运行以下命令

sudo apt-get clean
sudo apt-get install -f
sudo dpkg --configure -a
sudo apt-get update

命令 3

sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update

命令 4

sudo apt-get clean
sudo apt-get autoclean
sudo apt-get autoremove

命令 5

sudo dpkg --configure -a
sudo apt-get update

经过所有这些操作后,我仍然收到原始错误。有什么建议吗?除了格式化硬盘/重新安装操作系统外,我不知道还能做什么。

答案1

Durp,一旦我检查“软件和更新”中的“推荐更新(bionic-updates)”,原始的 apt-get install 命令就会起作用:

在此处输入图片描述

答案2

我遇到了同样的问题并尝试了许多解决方案但都失败了并出现以下消息。

    wasim@simsim:~/uStore-Auth$ sudo apt update && sudo apt install libsnmp-dev
                             
    .
    .
    .

    Fetched 768 kB in 3s (226 kB/s)     
    Reading package lists... Done 
    Building dependency tree       

    Reading state information... Done

    1 package can be upgraded. Run 'apt list --upgradable' to see it.

    Reading package lists... Done

    Building dependency tree       

    Reading state information... Done

    Package libsnmp-dev is not available, but is referred to by another 
    package.

    This may mean that the package is missing, has been obsoleted, or

    is only available from another source


    E: Package 'libsnmp-dev' has no installation candidate

我打开了软件和更新并标记了规范支持的免费和开源软件,如图所示。

并在其他软件选项卡中取消标记以下软件。您将拥有不同的软件,但请确保取消标记所有软件。

最后我使用相同的命令进行安装。

sudo apt-get install -y libsnmp-dev

答案3

你也可以像这样降级你的 libudev1:

sudo apt-get install --allow-downgrades libsnmp-dev libpci-dev libudev1=245.4-4ubuntu3.19

相关内容