我在 apt upgrade 后遇到问题并收到以下消息:
The following packages have unmet dependencies.
libnvidia-ifr1-390 : Depends: libnvidia-gl-390 but it is not installed
libnvidia-ifr1-390:i386 : Depends: libnvidia-gl-390:i386 but it is not installed
nvidia-driver-390 : Depends: libnvidia-gl-390 (= 390.87-0ubuntu0~gpu18.04.1) but it is not installed
Recommends: libnvidia-gl-390:i386 (= 390.87-0ubuntu0~gpu18.04.1)
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
之后我尝试 apt --fix-broken install,但得到:
dpkg-divert: error: mismatch on package
when removing 'diversion of /usr/lib/i386-linux-gnu/libGL.so.1 by libnvidia-gl-390'
found 'diversion of /usr/lib/i386-linux-gnu/libGL.so.1 to /usr/lib/i386-linux-gnu/libGL.so.1.distrib by nvidia-340'
dpkg: error processing archive /var/cache/apt/archives/libnvidia-gl-390_390.87-0ubuntu0~gpu18.04.1_i386.deb (--unpack):
new libnvidia-gl-390:i386 package pre-installation script subprocess returned error exit status 2
Preparing to unpack .../libnvidia-gl-390_390.87-0ubuntu0~gpu18.04.1_amd64.deb ...
diversion of /usr/lib/x86_64-linux-gnu/libGL.so to /usr/lib/x86_64-linux-gnu/libGL.so.distrib by nvidia-340
dpkg-divert: error: mismatch on package
when removing 'diversion of /usr/lib/x86_64-linux-gnu/libGL.so by libnvidia-gl-390'
found 'diversion of /usr/lib/x86_64-linux-gnu/libGL.so to /usr/lib/x86_64-linux-gnu/libGL.so.distrib by nvidia-340'
dpkg: error processing archive /var/cache/apt/archives/libnvidia-gl-390_390.87-0ubuntu0~gpu18.04.1_amd64.deb (--unpack):
new libnvidia-gl-390:amd64 package pre-installation script subprocess returned error exit status 2
Errors were encountered while processing:
/var/cache/apt/archives/libnvidia-gl-390_390.87-0ubuntu0~gpu18.04.1_i386.deb
/var/cache/apt/archives/libnvidia-gl-390_390.87-0ubuntu0~gpu18.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
然后我尝试解决方案 如何修复 ubuntu 18.04 LTS 上的这个 apt 问题?
sudo rm /var/cache/apt/archives/libnvidia-gl-390_390.87-0ubuntu0~gpu18.04.1_i386.deb
sudo rm /var/cache/apt/archives/libnvidia-gl-390_390.87-0ubuntu0~gpu18.04.1_amd64.deb
然后删除缓存中的所有下载文件。
sudo apt-get clean
sudo apt-get autoremove && sudo apt-get autoclean
我再次得到:
The following packages have unmet dependencies.
libnvidia-ifr1-390 : Depends: libnvidia-gl-390 but it is not installed
libnvidia-ifr1-390:i386 : Depends: libnvidia-gl-390:i386 but it is not installed
nvidia-driver-390 : Depends: libnvidia-gl-390 (= 390.87-0ubuntu0~gpu18.04.1) but it is not installed
Recommends: libnvidia-gl-390:i386 (= 390.87-0ubuntu0~gpu18.04.1)
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
我三周前将 ubuntu 从 16.04 版本更新到 18.04 - 但这个问题两天前就出现了。
有人可以帮忙吗?
答案1
它很可能没有正确安装。我可能会删除没有依赖项的软件包,如下所示:
sudo dpkg -r libnvidia-ifr1-390
sudo dpkg -r libnvidia-ifr1-390:i386
sudo dpkg -r nvidia-driver-390
使用这些命令应该释放 apt-get,现在您可以安装依赖项并重新安装驱动程序:(这应该会自动安装依赖项)
sudo apt-get install nvidia-driver-390
如果同样的事情再次发生,请尝试以下操作:(这将安装列出的依赖项和驱动程序)
sudo apt-get install libnvidia-gl-390:i386
sudo apt-get install libnvidia-gl-390
sudo apt-get install nvidia-driver-390
或者这样:(这将卸载并清除与 Nvidia 相关的任何安装内容并安装驱动程序,同时删除软件包的本地副本以再次下载)
sudo apt-get clean
sudo apt-get purge nvidia*
sudo apt-get autoremove --purge
sudo apt-get install nvidia-driver-390