[Help!!!]系统无法升级, apt-get无法工作... The package system is broken

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
dreamtang
帖子: 27
注册时间: 2008-03-22 0:00

[Help!!!]系统无法升级, apt-get无法工作... The package system is broken

#1

帖子 dreamtang » 2013-12-02 13:58

我的问题: 我的系统dpkg相关应用似乎已经崩溃了. 包括"Software up to date", "apt-get"都无法正常使用.

我的系统是: ubuntu 12.04 LTS...
我的硬件:

Memory: 3.9 GiB
Processor: Intel® Core™2 Duo CPU T6670 @ 2.20GHz × 2
Graphic: Unknown 显卡前几天坏了, 去店里修了说给换了个新的
os-type: 32-bit


前几天使用vim的时候发现没办法自动识别文件的编码格式, 发现没有安装vim, 就使用sudo apt-get install vim尝试安装, 结果出错.

后来我在"update manager"=>"左下角Settings"=>"Ubuntu Software"里将"Download from"修改为"Main", 再执行sudo apt-get update, 再尝试用sudo apt-get install vim安装还是不行.


然后我用sudo apt-get -f install, 最后到dpkg的时候报错了, 错误日志如下:

Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf.index...
Processing triggers for initramfs-tools ...
update-initramfs: Generating /boot/initrd.img-3.2.0-32-generic-pae
Errors were encountered while processing:
libqtgui4
libqt4-declarative
libqt4-opengl
libqt4-svg
checkbox-qt
libunity-2d-private0
unity-2d-panel
unity-2d-shell
unity-2d-spread
unity-2d
ubuntu-desktop
E: Sub-process /usr/bin/dpkg returned an error code (1)

我上网搜了以后, 还没有找到相关适用的解决方法, 还需要继续搜索... 但是我看到一个帖子==> http://askubuntu.com/questions/131791/q ... y-problems 说有类似的错误, 他最后的解决方法是:

I was able to fix this problem by removing the ubuntu-desktop package as well as unity-2d and all of the qt packages. Then, I reinstalled everything. Now, I can install packages without any trouble.

可是apt-get remove这种操作都失败了, 还有其他删除ubuntn-desktop, unity-2d, 所有qt packages的方法? 使用apt-get remove的时候会提示下面的错误:

$:sudo apt-get --purge remove ubuntu-desktop
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:
libqt4-declarative : Depends: libqt4-network (= 4:4.8.1-0ubuntu4.3) but 4:4.8.1-0ubuntu4.4 is to be installed
Depends: libqt4-script (= 4:4.8.1-0ubuntu4.3) but 4:4.8.1-0ubuntu4.4 is to be installed
Depends: libqt4-sql (= 4:4.8.1-0ubuntu4.3) but 4:4.8.1-0ubuntu4.4 is to be installed
Depends: libqt4-xmlpatterns (= 4:4.8.1-0ubuntu4.3) but 4:4.8.1-0ubuntu4.4 is to be installed
Depends: libqtcore4 (= 4:4.8.1-0ubuntu4.3) but 4:4.8.1-0ubuntu4.4 is to be installed
Depends: libqtgui4 (= 4:4.8.1-0ubuntu4.3) but 4:4.8.1-0ubuntu4.4 is to be installed
libqt4-opengl : Depends: libqtcore4 (= 4:4.8.1-0ubuntu4.3) but 4:4.8.1-0ubuntu4.4 is to be installed
Depends: libqtgui4 (= 4:4.8.1-0ubuntu4.3) but 4:4.8.1-0ubuntu4.4 is to be installed
libqt4-svg : Depends: libqtcore4 (= 4:4.8.1-0ubuntu4.3) but 4:4.8.1-0ubuntu4.4 is to be installed
Depends: libqtgui4 (= 4:4.8.1-0ubuntu4.3) but 4:4.8.1-0ubuntu4.4 is to be installed
libqtgui4 : Depends: libqt4-declarative (= 4:4.8.1-0ubuntu4.4) but 4:4.8.1-0ubuntu4.3 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

笔记本装了双系统, 希望能找到解决的思路, 恢复程序的安装和升级.

希望大家帮帮忙, 谢谢.
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: [Help!!!]系统无法升级, apt-get无法工作... The package system is br

#2

帖子 poloshiao » 2013-12-02 15:34

sudo apt-get --purge remove ubuntu-desktop
當你執行這個指令的時候 最好是 把 tty7 關閉 在 tty1 執行
程序
1. 按一下 alt + ctrl + F1 # 進入 tty1
2. 登入 帳號/密碼
3. sudo stop lightdm # 關閉 tty7
4. sudo apt-get --purge remove ubuntu-desktop

sudo apt-get purge ubuntu-desktop
意思一樣
5. sudo apt-get install ubuntu-desktop
6. 4 + 5 可以簡化爲
sudo apt-get install --reinstall ubuntu-desktop
但是 並不完全一樣
7. 安裝完畢
sudo reboot
dreamtang
帖子: 27
注册时间: 2008-03-22 0:00

Re: [Help!!!]系统无法升级, apt-get无法工作... The package system is br

#3

帖子 dreamtang » 2014-01-16 20:15

poloshiao 写了:
sudo apt-get --purge remove ubuntu-desktop
當你執行這個指令的時候 最好是 把 tty7 關閉 在 tty1 執行
程序
1. 按一下 alt + ctrl + F1 # 進入 tty1
2. 登入 帳號/密碼
3. sudo stop lightdm # 關閉 tty7
4. sudo apt-get --purge remove ubuntu-desktop

sudo apt-get purge ubuntu-desktop
意思一樣
5. sudo apt-get install ubuntu-desktop
6. 4 + 5 可以簡化爲
sudo apt-get install --reinstall ubuntu-desktop
但是 並不完全一樣
7. 安裝完畢
sudo reboot
谢谢poloshiao帮忙, 最后我用下面这两个命令解决了:

1. sudo dpkg --purge --force-depends "libqt*" 删除所有qt相关的依赖
2. sudo apt-get -f install
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: [Help!!!]系统无法升级, apt-get无法工作... The package system is br

#4

帖子 poloshiao » 2014-01-16 20:41

2. sudo apt-get -f install
Ubuntu 基於 Debian
所以也基於 Debian 的套件相依的概念
sudo apt-get install vim 安装还是不行
The following packages have unmet dependencies:
libqt4-declarative : Depends: libqt4-network (= 4:4.8.1-0ubuntu4.3) but 4:4.8.1-0ubuntu4.4 is to be installed
安裝某一個套件 例如 vim
碰到 某個相依套件 相依條件不滿足時 (例如 libqt4-script 版本不對)
通常是 放棄安裝
sudo apt-get -f install
這個指令 後面不必加套件名稱
意思是 所有因爲 相依套件 相依條件不滿足 而沒有安裝的套件 通通強制安裝該套件 (但是 放棄檢查 其相依套件是否條件滿足)
所以 包含 vim 已經順利安裝

但是 並不保證 所有的 vim 功能都可以充分支援 因爲有許多相依套件沒有安裝
所以 這只是暫時解決方案 不是完全解決方案
完全解決方案 是所有須要的相依套件 都必須條件滿足

1. 通常開始安裝某個套件以前如果先
sudo apt-get update
sudo apt-get upgrade
然後再開始安裝 vim 套件
sudo apt-get install vim
可以使得因爲相依套件條件不滿足的情況 減少到最少

2. 如果還是發生 相依套件條件不滿足的情況
換個 已經更新到最新版的 下載伺服器 再試試 1
https://launchpad.net/ubuntu/+archivemirrors
(最後一欄是綠色字)

3. 如果還是發生 相依套件條件不滿足的情況
3-1. 先把 Ubuntu 整個作業系統備存起來
(雖然風險很小 但是 備存永遠是 好習慣)
3-2. 再試一次
sudo apt-get update
sudo apt-get dist-upgrade
然後再開始安裝 vim 套件
sudo apt-get install vim
3-3. 如果還有錯誤訊息 請直接 copy 貼上來
回复