如何解决未满足的依赖关系?无法安装或删除软件包

如何解决未满足的依赖关系?无法安装或删除软件包
$sudo apt-get -f install google-chrome-stable

我尝试在 ubuntu 中安装 java,但未成功安装,但之后当我尝试安装/删除任何其他软件包时,出现以下错误:

Reading package lists... Done  
Building dependency tree  
Reading state information... Done  
You might want to run 'apt-get -f install' to correct these:  

The following packages have unmet dependencies:

    bleachbit : Depends: menu but it is not going to be installed

    ca-certificates-java : Depends: openjdk-6-jre-headless (>= 6b16-1.6.1-2) or
                                    java6-runtime-headless

    icedtea-6-plugin : Depends: openjdk-6-jre

    icedtea-netx : Depends: openjdk-6-jre (>= 6b23~pre10~) or
                            openjdk-7-jre

**E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).**

当我运行sudo dpkg --configure -a以获取所有依赖项时,我发现:

dpkg: dependency problems prevent configuration of icedtea-netx:    

icedtea-netx depends on openjdk-6-jre (>= 6b23~pre10~) | openjdk-7-jre; however:   
Package openjdk-6-jre is not installed.  
Package openjdk-7-jre is not installed.

dpkg: error processing icedtea-netx (--configure):

dependency problems - leaving unconfigured

dpkg: dependency problems prevent configuration of bleachbit:

bleachbit depends on python-central (>= 0.6.7); however:

  Package python-central is not installed.

  bleachbit depends on menu; however:

  Package menu is not installed.


dpkg: error processing bleachbit (--configure):

 dependency problems - leaving unconfigured

dpkg: dependency problems prevent configuration of ca-certificates-java:

 ca-certificates-java depends on openjdk-6-jre-headless (>= 6b16-1.6.1-2) | java6-runtime-headless; however:

  Package openjdk-6-jre-headless is not installed.

  Package java6-runtime-headless is not installed.

dpkg: error processing ca-certificates-java (--configure):
 dependency problems - leaving unconfigured

dpkg: dependency problems prevent configuration of icedtea-6-plugin:

 icedtea-6-plugin depends on openjdk-6-jre; however:  Package openjdk-6-jre is not installed.   icedtea-6-plugin depends on icedtea-netx (= 1.2-2ubuntu1); however:
 Package icedtea-netx is not configured yet.



dpkg: error processing icedtea-6-plugin (--configure):

 dependency problems - leaving unconfigured

Errors were encountered while processing:

    icedtea-netx

    bleachbit

    ca-certificates-java

    icedtea-6-plugin

当我打开 ubuntu soft.center 安装/删除任何软件包时,我也收到此错误:

Package dependencies cannot be resolved

The following packages have unmet dependencies:

bleachbit: Depends: python (>= 2.4) but 2.7.3-0ubuntu2 is installed
       Depends: python-gtk2 (>= 2.6) but 2.24.0-3 is installed
       Depends: python-central (>= 0.6.7) but it is not installed
       Depends: menu but it is not installed

 ca-certificates-java: Depends: java6-runtime-headless but it is a virtual package
 icedtea-6-plugin: Depends: openjdk-6-jre but it is not installed
              Depends: icedtea-netx (= 1.2-2ubuntu1) but 1.2-2ubuntu1 is installed
              Depends: libc6 (>= 2.4) but 2.15-0ubuntu10.3 is installed
              Depends: libgcc1 (>= 1:4.1.1) but 1:4.6.3-1ubuntu5 is installed
              Depends: libglib2.0-0 (>= 2.31.8) but 2.32.3-0ubuntu1 is installed
              Depends: libgtk2.0-0 (>= 2.8.0) but 2.24.10-0ubuntu6 is installed
              Depends: libstdc++6 (>= 4.6) but 4.6.3-1ubuntu5 is installed

  icedtea-netx: Depends: icedtea-netx-common (>= 1.2-2ubuntu1) but 1.2-2ubuntu1 is installed
          Depends: openjdk-7-jre but it is not installed

答案1

尝试手动安装 openjdk-6-jre (sudo apt-get install openjdk-6-jre) - 如果无法安装,请运行“apt-cache policy openjdk-6-jre”以查看是否有源。如果没有源,您会错过 /etc/apt/sources.list 中的 universe 和/或 security 源。可能您还错过了“sudo apt-get update”?

或者尝试使用以下命令删除软件包:

sudo dpkg --purge bleachbit ca-certificates-java icedtea-6-plugin icedtea-netx

然后再次尝试安装您想要安装的内容或仅安装 oracle java:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

答案2

我觉得你搞混aptdpkg。你明白了

Try 'apt-get -f install' with no packages (or specify a solution)

但你没有apt-get -f install执行sudo dpkg --configure -a“获取所有依赖项”。那不是这样dpkg做的。

来自的手册页dpkg

   --configure package...|-a|--pending
          Configure a package which has been unpacked but not yet  config‐
          ured.   If  -a  or  --pending  is  given instead of package, all
          unpacked but unconfigured packages are configured.

这不是问题所在。显然,dpkg由于未满足依赖关系,无法成功配置某些软件包——而不是因为软件包的解压因某种原因而中断。通过安装缺失的软件包来解决依赖关系属于 apt 的范畴。摘自 apt-get 手册页:

   -f, --fix-broken
       Fix; attempt to correct a system with broken dependencies in place.
       This option, when used with install/remove, can omit any packages
       to permit APT to deduce a likely solution. If packages are
       specified, these have to completely correct the problem. 

因此,错误消息所宣传的命令是:

sudo apt-get install -f

从您复制粘贴的内容中显示的实际损坏依赖关系来看,我认为这个简单的命令应该可以解决问题。如果不行,请参阅此问题或者从上述命令发布确切的错误消息。

造成这种情况的原因可能是您事先没有做任何准备apt-get update。apt 保存的软件包列表指向存储库中的各个软件包。当存储库中的一个或多个软件包因任何原因升级时,旧软件包将被清除。依赖软件包则指向不再提供的软件包。

您不必apt-get update每次安装时都运行,但您可能会遇到这种情况。不过,这可以通过 轻松解决sudo apt-get update && sudo apt-get install -f

相关内容