系統更新錯誤訊息:
包系統壞了
檢查您是否使用第三方儲存庫。如果是這樣,請停用它們,因為它們是問題的常見根源。此外,在終端機中執行以下命令: apt-get install -f 當我嘗試時sudo apt-get istall -f
收到錯誤訊息:
(Reading database ... 172407 files and directories currently installed.)
Preparing to unpack .../libnvidia-gl-390_390.59-0ubuntu0~gpu18.04.1_i386.deb ...
diversion of /usr/lib/i386-linux-gnu/libGL.so.1 to /usr/lib/i386-linux-gnu/libGL.so.1.distrib by nvidia-340
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.59-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.59-0ubuntu0~gpu18.04.1_amd64.deb ...
diversion of /usr/lib/x86_64-linux-gnu/libGL.so.1 to /usr/lib/x86_64-linux-gnu/libGL.so.1.distrib by nvidia-340
dpkg-divert: error: mismatch on package
when removing 'diversion of /usr/lib/x86_64-linux-gnu/libGL.so.1 by libnvidia-gl-390'
found 'diversion of /usr/lib/x86_64-linux-gnu/libGL.so.1 to /usr/lib/x86_64-linux-gnu/libGL.so.1.distrib by nvidia-340'
dpkg: error processing archive /var/cache/apt/archives/libnvidia-gl-390_390.59-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.59-0ubuntu0~gpu18.04.1_i386.deb
/var/cache/apt/archives/libnvidia-gl-390_390.59-0ubuntu0~gpu18.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
我怎樣才能解決這個問題 ?
答案1
首先使用刪除.deb
sudo rm /var/cache/apt/archives/libnvidia-gl-390_390.59-0ubuntu0~gpu18.04.1_i386.deb
sudo rm /var/cache/apt/archives/libnvidia-gl-390_390.59-0ubuntu0~gpu18.04.1_amd64.deb
然後刪除快取中所有下載的檔案。
sudo apt-get clean
sudo apt-get autoremove && sudo apt-get autoclean
sudo apt-get install -f
sudo apt-get update
最後嘗試使用 sudo apt-get install 安裝應用程式的新副本
答案2
錯誤訊息的相關部分是這樣的:
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 的事。 Nvidia-340 軟體包一定創建了這些轉移並且從未刪除它們。要檢查,請執行
dpkg-divert --list nvidia-340
它將列出指定的每個轉移。
diversion of /usr/lib/x86_64-linux-gnu/libGL.so.1 to /usr/lib/x86_64-linux-gnu/libGL.so.1.distrib by nvidia-340
...
您可以透過將轉移的檔案名稱傳遞給(需要root)來刪除這些轉移
dpkg-divert --remove /usr/lib/x86_64-linux-gnu/libGL.so.1
清理舊的轉移後,安裝較新的 Nvidia 驅動程式套件apt
應該會成功。