无法解析程序包依赖性

我试图在Ubuntu中安装java,但它给了我这个错误:

$ sudo apt-get install default-jre 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: default-jre : Depends: default-jre-headless (= 1:1.6-43ubuntu2) but it is not going to be installed Depends: openjdk-6-jre (>= 6b23~pre11-1ubuntu1~) but it is not going to be installed E: Unable to correct problems, you have held broken packages. 

当我尝试从软件中心安装任何东西时

它向我显示了这个错误:

[ 无法解析包依赖项

当我转到软件中心>编辑>软件源被禁用时。

我尝试了很多解决方案但没有任何效果:

 sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgrade sudo apt-get clean sudo apt-get autoclean 

我试过这个Stack Overflow的答案

这是apt-cache policy default-jreapt-cache policy default-jre-headless

 $ apt-cache policy default-jre default-jre: Installed: (none) Candidate: 1:1.6-43ubuntu2 Version table: 1:1.6-43ubuntu2 0 500 http://us.archive.ubuntu.com/ubuntu/ precise/main i386 Packages $ apt-cache policy default-jre-headless default-jre-headless: Installed: (none) Candidate: 1:1.6-43ubuntu2 Version table: 1:1.6-43ubuntu2 0 500 http://us.archive.ubuntu.com/ubuntu/ precise/main i386 Packages 

当我尝试dpkg --get-selections | grep hold dpkg --get-selections | grep hold it不显示任何错误!

以为它本来是来自实际的“持有”套餐,但也许不是,或者可能不是唯一的问题……

我在使用非标准存储库(错误的版本/发行版,奇数私有或PPA)之前看到过类似的错误。 您可能想要检查您的存储库并尝试将其重置为“默认值”。

可能无法解决问题,但制作当前repos(sources.list …文件)的备份副本将很容易检查并稍后撤消。

这是我恢复默认Ubuntu源的另一个答案的信息:

备份sources.list文件

只需将它们复制到某处的备份文件夹,这应该可行:

 sudo cp /etc/apt/sources.list /etc/apt/sources.list.old sudo cp -R /etc/apt/sources.list.d /etc/apt/sources.list.d.old 

或者把副本放在你家的某个地方:

 sudo cp -R /etc/apt/sources.list* /home/myuser/ 

恢复默认的Ubuntu sources.list

  • 对于Ubuntu,如果你这样做,它应该生成一个新的sources.list文件

    1. 删除旧文件( sudo rm /etc/apt/sources.listsudo rm -R /etc/apt/sources.list.d但是BACKUP FIRST )。

    2. 然后做以下任何一个:

      • 运行软件源(从程序菜单/破折号,或sudo software-properties-gtksudo software-sources )选择/勾选一些repos,选择服务器并更新。

      • 或者使用您的版本和国家/地区在http://repogen.simplylinux.ch/上生成一个新的(选择本地镜像),然后将其复制并粘贴到新的sources.list中
        gksudo gedit /etc/apt/sources.list
        或者在一个终端上
        sudo nano /etc/apt/sources.list

网站http://repogen.simplylinux.ch/也有很多可选的PPA。 [ 如何恢复默认存储库? ]