问题现象
Unpacking nvidia-340 (340.107-0ubuntu0~gpu18.04.1) ... dpkg: error processing archive /var/cache/apt/archives/nvidia-340_340.107-0ubuntu0~gpu18.04.1_amd64.deb (--unpack): trying to overwrite '/lib/udev/rules.d/71-nvidia.rules', which is also in package nvidia-kernel-common-396 396.45-0ubuntu0~gpu18.04.2 dpkg-deb: error: paste subprocess was killed by signal (Broken pipe) Errors were encountered while processing: /var/cache/apt/archives/nvidia-340_340.107-0ubuntu0~gpu18.04.1_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1)
解决办法
使用下面指令,它将解决“试图覆盖错误”与强大的dpkg的力量。
sudo dpkg -i --force-overwrite /var/cache/apt/archives/nvidia-340_340.107-0ubuntu0~gpu18.04.1_amd64.deb
//注意最后 /var....amd64.deb 部分,是你报错误的文件路径名称
然后运行下面指令,修复任何损坏的包。
sudo apt -f install