我正在尝试升级 apt,但出现以下错误。我该如何修复它?
mona@goku:~$ sudo apt update
Hit:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu focal InRelease
Hit:3 https://download.docker.com/linux/ubuntu focal InRelease
Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:5 http://ppa.launchpad.net/nm-l2tp/network-manager-l2tp/ubuntu focal InRelease
Hit:6 http://deb.anydesk.com all InRelease
Hit:7 https://packages.microsoft.com/repos/ms-teams stable InRelease
Hit:8 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:9 http://archive.ubuntu.com/ubuntu xenial InRelease
Hit:10 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:11 http://lenovo.archive.canonical.com focal InRelease
Hit:12 http://ppa.launchpad.net/zeehio/libxp/ubuntu focal InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
119 packages can be upgraded. Run 'apt list --upgradable' to see them.
mona@goku:~$ sudo apt upgrade
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:
libopencv-highgui2.4v5 : Depends: libpng12-0 (>= 1.2.13-4) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
mona@goku:~$ sudo apt full-upgrade
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:
libopencv-highgui2.4v5 : Depends: libpng12-0 (>= 1.2.13-4) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
mona@goku:~$ 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:
cpp-7 libpython-dev libpython2.7-dev libpython3-dev python2.7-dev python3-decorator python3-ipython-genutils
python3-jupyter-core python3-traitlets python3.8-dev
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libpng12-0
The following NEW packages will be installed:
libpng12-0
0 upgraded, 1 newly installed, 0 to remove and 119 not upgraded.
5 not fully installed or removed.
Need to get 0 B/116 kB of archives.
After this operation, 285 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 408627 files and directories currently installed.)
Preparing to unpack .../libpng12-0_1.2.54-1ubuntu1_amd64.deb ...
Unpacking libpng12-0:amd64 (1.2.54-1ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/libpng12-0_1.2.54-1ubuntu1_amd64.deb (--unpack):
unable to install new version of '/lib/x86_64-linux-gnu/libpng12.so.0': No such file or directory
No apport report written because the error message indicates an issue on the local system
Errors were encountered while p
rocessing:
/var/cache/apt/archives/libpng12-0_1.2.54-1ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
和
mona@goku:~$ sudo apt-get -f 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:
cpp-7 libpython-dev libpython2.7-dev libpython3-dev python2.7-dev python3-decorator python3-ipython-genutils
python3-jupyter-core python3-traitlets python3.8-dev
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libpng12-0
The following NEW packages will be installed:
libpng12-0
0 upgraded, 1 newly installed, 0 to remove and 119 not upgraded.
5 not fully installed or removed.
Need to get 0 B/116 kB of archives.
After this operation, 285 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 408627 files and directories currently installed.)
Preparing to unpack .../libpng12-0_1.2.54-1ubuntu1_amd64.deb ...
Unpacking libpng12-0:amd64 (1.2.54-1ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/libpng12-0_1.2.54-1ubuntu1_amd64.deb (--unpack):
unable to install new version of '/lib/x86_64-linux-gnu/libpng12.so.0': No such file or directory
No apport report written because the error message indicates an issue on the local system
Errors were encountered while processing:
/var/cache/apt/archives/libpng12-0_1.2.54-1ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
和
mona@goku:~$ sudo dpkg --configure -a
dpkg: dependency problems prevent configuration of libopencv-highgui2.4v5:amd64:
libopencv-highgui2.4v5:amd64 depends on libpng12-0 (>= 1.2.13-4); however:
Package libpng12-0:amd64 is not installed.
dpkg: error processing package libopencv-highgui2.4v5:amd64 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libopencv-objdetect2.4v5:amd64:
libopencv-objdetect2.4v5:amd64 depends on libopencv-highgui2.4v5 (= 2.4.9.1+dfsg-1.5ubuntu1); however:
Package libopencv-highgui2.4v5:amd64 is not configured yet.
dpkg: error processing package libopencv-objdetect2.4v5:amd64 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libopencv-contrib2.4v5:amd64:
libopencv-contrib2.4v5:amd64 depends on libopencv-highgui2.4v5 (= 2.4.9.1+dfsg-1.5ubuntu1); however:
Package libopencv-highgui2.4v5:amd64 is not configured yet.
libopencv-contrib2.4v5:amd64 depends on libopencv-objdetect2.4v5 (= 2.4.9.1+dfsg-1.5ubuntu1); however:
Package libopencv-objdetect2.4v5:amd64 is not configured yet.
dpkg: error processing package libopencv-contrib2.4v5:amd64 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libopencv-legacy2.4v5:amd64:
libopencv-legacy2.4v5:amd64 depends on libopencv-highgui2.4v5 (= 2.4.9.1+dfsg-1.5ubuntu1); however:
Package libopencv-highgui2.4v5:amd64 is not configured yet.
dpkg: error processing package libopencv-legacy2.4v5:amd64 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-opencv:
python-opencv depends on libopencv-contrib2.4v5; however:
Package libopencv-contrib2.4v5:amd64 is not configured yet.
python-opencv depends on libopencv-highgui2.4v5; however:
Package libopencv-highgui2.4v5:amd64 is not configured yet.
python-opencv depends on libopencv-legacy2.4v5; however:
Package libopencv-legacy2.4v5:amd64 is not configured yet.
python-opencv depends on libopencv-objdetect2.4v5; however:
Package libopencv-objdetect2.4v5:amd64 is not configured yet.
dpkg: error processing package python-opencv (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.31-0ubuntu9.1) ...
Errors were encountered while processing:
libopencv-highgui2.4v5:amd64
libopencv-objdetect2.4v5:amd64
libopencv-contrib2.4v5:amd64
libopencv-legacy2.4v5:amd64
python-opencv
和
mona@goku:~$ 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:
libopencv-highgui2.4v5 : Depends: libpng12-0 (>= 1.2.13-4) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
和:
mona@goku:~$ namei -l /lib/x86_64-linux-gnu/libpng12.so.0
f: /lib/x86_64-linux-gnu/libpng12.so.0
drwxr-xr-x root root /
lrwxrwxrwx root root lib -> usr/lib
drwxr-xr-x root root usr
drwxr-xr-x root root lib
drwxr-xr-x root root x86_64-linux-gnu
libpng12.so.0 - No such file or directory
和
mona@goku:~$ sudo apt purge libopencv-highgui2.4v5 libpng12-0
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'libpng12-0' is not installed, so not removed
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
libopencv-contrib2.4v5 : Depends: libopencv-highgui2.4v5 (= 2.4.9.1+dfsg-1.5ubuntu1) but it is not going to be installed
libopencv-legacy2.4v5 : Depends: libopencv-highgui2.4v5 (= 2.4.9.1+dfsg-1.5ubuntu1) but it is not going to be installed
libopencv-objdetect2.4v5 : Depends: libopencv-highgui2.4v5 (= 2.4.9.1+dfsg-1.5ubuntu1) but it is not going to be installed
python-opencv : Depends: libopencv-highgui2.4v5 but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
答案1
sarnold
Ubuntu IRC 频道的解决方案:
$ sudo apt purge libopencv-highgui2.4v5 libpng12-0 libopencv-contrib2.4v5 libopencv-legacy2.4v5 libopencv-objdetect2.4v5 python-opencv
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'libpng12-0' is not installed, so not removed
The following packages were automatically installed and are no longer required:
cpp-7 libavcodec-ffmpeg56 libavformat-ffmpeg56 libavutil-ffmpeg54 libbluray1 libcrystalhd3 libilmbase12 libjasper1
libopencv-calib3d2.4v5 libopencv-core2.4v5 libopencv-features2d2.4v5 libopencv-flann2.4v5 libopencv-imgproc2.4v5
libopencv-ml2.4v5 libopencv-photo2.4v5 libopencv-video2.4v5 libopenexr22 libopenjpeg5 libpython-dev libpython2.7
libpython2.7-dev libpython3-dev libschroedinger-1.0-0 libswresample-ffmpeg1 libswscale-ffmpeg3 libva1 libvpx3
libwebp5 libx264-148 libx265-79 python2.7-dev python3-decorator python3-ipython-genutils python3-jupyter-core
python3-traitlets python3.8-dev
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
libopencv-contrib2.4v5* libopencv-highgui2.4v5* libopencv-legacy2.4v5* libopencv-objdetect2.4v5* python-opencv*
0 upgraded, 0 newly installed, 5 to remove and 119 not upgraded.
5 not fully installed or removed.
After this operation, 4,305 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 408627 files and directories currently installed.)
Removing python-opencv (2.4.9.1+dfsg-1.5ubuntu1) ...
Removing libopencv-contrib2.4v5:amd64 (2.4.9.1+dfsg-1.5ubuntu1) ...
Removing libopencv-objdetect2.4v5:amd64 (2.4.9.1+dfsg-1.5ubuntu1) ...
Removing libopencv-legacy2.4v5:amd64 (2.4.9.1+dfsg-1.5ubuntu1) ...
Removing libopencv-highgui2.4v5:amd64 (2.4.9.1+dfsg-1.5ubuntu1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.1) ...