最近我升级到Ubuntu 16
了Ubuntu 18
。一切看起来都比以前漂亮,而且运行良好。但是,我无法安装或删除任何软件包。我研究了这个论坛上的多个答案。但没有一个解决方案对我有用。以下是我执行的步骤。
$ sudo apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
imagemagick-6.q16 : Breaks: libmagickcore-dev (< 8:6.9.2.10+dfsg-2~) but 8:6.7.7.10-6ubuntu3.12 is installed
libmagick++-6.q16-dev : Breaks: libmagick++-dev (< 8:6.8.3.10-1~)
libmagick++-dev : Depends: libmagickwand-dev (= 8:6.7.7.10-6ubuntu3.12) but it is not installed
libmagickcore-6.q16-dev : Breaks: libmagickcore-dev (< 8:6.8.3.10-1~) but 8:6.7.7.10-6ubuntu3.12 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
根据输出中的建议,我执行下一个命令:
$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
gnome-keyring-pkcs11:i386 gstreamer1.0-nice hardening-includes icc-profiles-free imagemagick-common libaccount-plugin-google libaether-java libamd2.2.0 libantlr4-runtime-java
libapache2-mod-php libapache2-mod-php7.0 libapparmor-perl libappstream3 libasm3-java libasm4-java libasync-http-client-java libautodie-perl libavcodec53 libavformat53 libavutil51
libbatik-java libbind9-90 libblas3gf libchamplain-gtk-0.12-0 libclassworlds-java libcloog-isl4 libclutter-gst-2.0-0 libcodenarc-groovy-java libcolamd2.8.0 libcolorhug1
libcommons-beanutils-java libcommons-collections4-java libcommons-compress-java libcommons-configuration-java libcommons-digester-java libcommons-httpclient-java
libcommons-jexl2-java libcommons-jxpath-java libcommons-net2-java libcommons-vfs-java libdbd-mysql-perl libdbi-perl libdns100 libdoxia-core-java libdoxia-java libeasymock-java
libefivar0 libexiv2-12 libfontbox-java libfop-java libfwup0 libfwupd1 libgadu3 libgcrypt11:i386 libgegl-0.2-0 libgeronimo-ejb-3.2-spec-java libgeronimo-jpa-2.0-spec-java
libgeronimo-osgi-support-java libgeronimo-validation-1.0-spec-java libgif4 libgif4:i386 libgmetrics-groovy-java libgnuinet-java libgnujaf-java libgnumail-java libgnutls-openssl27
libgnutls26:i386 libgphoto2-port10 libgphoto2-port10:i386 libgraphviz-dev libgstreamer-plugins-base0.10-0:i386 libgstreamer0.10-0:i386 libgtkspell3-3-0 libgvc6-plugins-gtk
libgweather-3-6 libhud2 libilmbase6 libisc95 libisccc90 libisccfg90 libisl10 libisl15 libitext1-java libjackrabbit-java libjaffl-java libjasper-dev libjavascriptcoregtk-1.0-0
libjctools-java libjetty-extra libjetty-extra-java libjetty-java libjffi-java libjffi-jni libjnr-constants-java libjnr-ffi-java libjnr-posix-java libjnr-x86asm-java
libjson-c2:i386 liblept4 liblinear1 liblwres90 libmagick++5 libmagickcore-dev libmagickcore5 libmagickcore5-extra libmagickwand5 libmaven-ant-tasks-java libmaven-archiver-java
libmaven-scm-java libmaven2-core-java libmockobjects-java libmodello-java libmx4j-java libmysqlclient18:i386 libmysqlclient20 libnet-daemon-perl libnetty-java libopenexr6
libopenraw1 libosgi-foundation-ee-java libp11-kit-gnome-keyring libp11-kit-gnome-keyring:i386 libpackagekit-glib2-16 libparboiled-java libpegdown-java libplexus-ant-factory-java
libplexus-archiver-java libplexus-bsh-factory-java libplexus-build-api-java libplexus-classworlds2-java libplexus-cli-java libplexus-i18n-java libplexus-interactivity-api-java
libplexus-io-java libpng12-0:i386 libpoppler-qt4-4 libpoppler44 libprocps3 libprotobuf-c1 libprotobuf8 libprotoc8 libqt5opengl5 libqt5organizer5 libqtwebkit4 libraw9 libsaxon-java
libschroedinger-1.0-0 libservlet2.5-java libservlet3.0-java libsisu-guice-java libsisu-ioc-java libsnappy-java libsnappy-jni libspice-client-gtk-3.0-4 libspring-aop-java
libspring-context-java libspring-expression-java libspring-instrument-java libsub-identify-perl libsystemd-login0 libterm-readkey-perl libtesseract3 libtinyxml2.6.2
libtomcat7-java libtxc-dxtn-s2tc0 libtxc-dxtn-s2tc0:i386 libufe-xidgetter0 libumfpack5.4.0 libunity-action-qt1 libustr-1.0-1 libva1 libvpx1 libvpx3 libvpx3:i386 libwagon-ftp-java
libwagon-java libwagon2-java libwebkitgtk-1.0-0 libwebpmux1 libwxbase2.8-0 libwxgtk2.8-0 libxbean-java libxdot4 libxmlgraphics-commons-java libxtables10 linux-headers-3.13.0-156
linux-headers-3.13.0-156-generic linux-image-3.13.0-156-generic linux-image-extra-3.13.0-156-generic odbcinst odbcinst1debian2 oxideqt-codecs p11-kit-modules:i386 pgdg-keyring
pidgin-data plainbox-provider-checkbox plainbox-provider-resource-generic python-certifi python-distlib python-pyatspi python-requests python3-pycurl
qtdeclarative5-accounts-plugin qtdeclarative5-localstorage-plugin qtdeclarative5-unity-action-plugin signon-keyring-extension signon-plugin-password signon-ui snapd-login-service
tesseract-ocr-equ ubuntu-ui-toolkit-theme unixodbc wine-gecko2.21 wine-gecko2.21:i386 wine-mono0.0.8 wine1.6-amd64 wine1.6-i386:i386
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libmagick++-dev libmagickcore-dev
The following packages will be upgraded:
libmagick++-dev libmagickcore-dev
2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
3 not fully installed or removed.
Need to get 0 B/2,780 B of archives.
After this operation, 6,226 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 1227136 files and directories currently installed.)
Preparing to unpack .../libmagick++-dev_8%3a6.9.7.4+dfsg-16ubuntu6.3_all.deb ...
dpkg-query: no packages found matching libmagick++-dev:all
dpkg-query: package 'libmagick++-dev' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
dpkg-maintscript-helper: error: file '/usr/share/doc/libmagick++-dev' not owned by package 'libmagick++-dev:all'
dpkg-query: package 'libmagick++-dev' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
dpkg-maintscript-helper: error: file '/usr/share/doc/libmagick++-dev/NEWS.Debian.gz' not owned by package 'libmagick++-dev:all'
dpkg-query: package 'libmagick++-dev' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
dpkg-maintscript-helper: error: file '/usr/share/doc/libmagick++-dev/changelog.Debian.gz' not owned by package 'libmagick++-dev:all'
dpkg-query: package 'libmagick++-dev' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
dpkg-maintscript-helper: error: file '/usr/share/doc/libmagick++-dev/copyright' not owned by package 'libmagick++-dev:all'
dpkg-maintscript-helper: error: directory '/usr/share/doc/libmagick++-dev' contains files not owned by package libmagick++-dev:all, cannot switch to symlink
dpkg: error processing archive /var/cache/apt/archives/libmagick++-dev_8%3a6.9.7.4+dfsg-16ubuntu6.3_all.deb (--unpack):
new libmagick++-dev package pre-installation script subprocess returned error exit status 1
Preparing to unpack .../libmagickcore-dev_8%3a6.9.7.4+dfsg-16ubuntu6.3_all.deb ...
dpkg-query: no packages found matching libmagickcore-dev:all
dpkg-query: package 'libmagickcore-dev' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
dpkg-maintscript-helper: error: file '/usr/share/doc/libmagickcore-dev' not owned by package 'libmagickcore-dev:all'
dpkg-query: package 'libmagickcore-dev' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
dpkg-maintscript-helper: error: file '/usr/share/doc/libmagickcore-dev/NEWS.Debian.gz' not owned by package 'libmagickcore-dev:all'
dpkg-query: package 'libmagickcore-dev' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
dpkg-maintscript-helper: error: file '/usr/share/doc/libmagickcore-dev/changelog.Debian.gz' not owned by package 'libmagickcore-dev:all'
dpkg-query: package 'libmagickcore-dev' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
dpkg-maintscript-helper: error: file '/usr/share/doc/libmagickcore-dev/copyright' not owned by package 'libmagickcore-dev:all'
dpkg-maintscript-helper: error: directory '/usr/share/doc/libmagickcore-dev' contains files not owned by package libmagickcore-dev:all, cannot switch to symlink
dpkg: error processing archive /var/cache/apt/archives/libmagickcore-dev_8%3a6.9.7.4+dfsg-16ubuntu6.3_all.deb (--unpack):
new libmagickcore-dev package pre-installation script subprocess returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/libmagick++-dev_8%3a6.9.7.4+dfsg-16ubuntu6.3_all.deb
/var/cache/apt/archives/libmagickcore-dev_8%3a6.9.7.4+dfsg-16ubuntu6.3_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
我已根据在线论坛的帮助尝试了以下命令,但以下命令均不起作用:
sudo apt-get clean
sudo apt-get autoclean
sudo apt-get autoremove
sudo apt-get -f install
sudo apt-get upgrade
sudo apt-get --purge remove package_name
花了几乎一整天的时间后,我从这个论坛的一个答案中找到了一条建议。因此,我从名为 的文件逐一删除了所有提到的损坏软件包信息/var/lib/dpkg/status
。
我知道,这是一个非常繁琐的过程。但这对我来说是唯一有用的方法。
答案2
备份您的状态文件... 一般来说,不要随便从/var/
或其他重要的地方删除东西。
sudo mv /var/lib/dpkg/status /var/lib/dpkg/status.bak
创建新的空文件
touch /var/lib/dpkg/status
运行更新然后升级
sudo apt update && sudo apt upgrade
或者...用一行:
sudo mv /var/lib/dpkg/status /var/lib/dpkg/_status && touch /var/lib/dpkg/status && sudo apt update && sudo apt upgrade