在 Ubuntu 16.04 上安装 Nvidia、Cuda 以及升级 Ubuntu 时出现的问题

在 Ubuntu 16.04 上安装 Nvidia、Cuda 以及升级 Ubuntu 时出现的问题

我在安装 Nvidia 时遇到问题。我尝试了很多解决方案,但都不起作用。我甚至无法打开Software Updater

在此处输入图片描述

#Python 3.7.4
#tensorflow-gpu 2.2.0

import tensorflow as tf

print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))

可用 GPU 数量:0

$lspci | grep -i --color 'vga\|3d\|2d'

01:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)

$nvidia-smi

NVIDIA: could not open the device file /dev/nvidiactl (No such file or directory).
NVIDIA-SMI has failed because it couldn't communicate with NVIDIA driver. Make sure that latest NVIDIA driver is installed and running.

这是我在 Ubuntu 16.04 上尝试安装 Nvidia 和 Cuda 时遇到的所有问题的列表。

$sudo apt-get purge nvidia*

...
cuda-drivers : Depends: nvidia-384 (>= 384.81)
                Depends: nvidia-384-dev (>= 384.81) but it is not going to be installed
                Depends: nvidia-modprobe (>= 384.81) but it is not going to be installed
                Depends: nvidia-settings (>= 384.81) but it is not going to be installed
                Depends: nvidia-opencl-icd-384 (>= 384.81) but it is not going to be installed
 libcuda1-384 : Depends: nvidia-384 (>= 384.130)
 update-notifier : Depends: update-notifier-common (= 3.168.13) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution)

$sudo dpkg --configure -a

> dpkg: error processing package python3-apt (--configure):  package is
> in a very bad inconsistent state; you should  reinstall it before
> attempting configuration Errors were encountered while processing: 
> `python3-apt`

$sudo apt-get remove package*

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'packagekit-dbg' for glob 'package*'
Note, selecting 'packagekit-gtk3-module' for glob 'package*'
Note, selecting 'packagekit-offline-update' for glob 'package*'
Note, selecting 'packagekit-system-interface' for glob 'package*'
Note, selecting 'packagekit-tools' for glob 'package*'
Note, selecting 'packagekit-gnome' for glob 'package*'
Note, selecting 'packagekit-docs' for glob 'package*'
Note, selecting 'packagesearch' for glob 'package*'
Note, selecting 'packagekit-backend-aptcc' for glob 'package*'
Note, selecting 'packagekit' for glob 'package*'
Note, selecting 'packagekit-backend-smart' for glob 'package*'
Note, selecting 'packagekit-plugin-click' for glob 'package*'
Note, selecting 'packagekit-backend-apt' for glob 'package*'
Package 'packagekit-backend-apt' is not installed, so not removed
Package 'packagekit-offline-update' is not installed, so not removed
Package 'packagekit-gnome' is not installed, so not removed
Package 'packagesearch' is not installed, so not removed
Package 'packagekit' is not installed, so not removed
Package 'packagekit-backend-aptcc' is not installed, so not removed
Package 'packagekit-docs' is not installed, so not removed
Package 'packagekit-tools' is not installed, so not removed
Package 'packagekit-backend-smart' is not installed, so not removed
Package 'packagekit-dbg' is not installed, so not removed
Package 'packagekit-gtk3-module' is not installed, so not removed
Package 'packagekit-plugin-click' is not installed, so not removed
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 cuda-drivers : Depends: nvidia-settings (>= 384.81) but 361.42-0ubuntu1 is to be installed
 nvidia-304 : Conflicts: xorg-driver-binary
              Recommends: libcuda1-304 but it is not going to be installed
              Recommends: nvidia-opencl-icd-304 but it is not going to be installed
 nvidia-384 : Conflicts: xorg-driver-binary
 update-notifier : Depends: update-notifier-common (= 3.168.13) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
ipc@ipc-System-Product-Name:~$ apt --fix-broken install
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
ipc@ipc-System-Product-Name:~$ 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:
  libxapian-1.3-5 libxapian-dev python3-xapian1.3 xapian-doc xapian-examples
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libnvidia-compute-460 python3-apt update-notifier-common
Suggested packages:
  python3-apt-dbg python-apt-doc
The following packages will be REMOVED:
  cuda-9-0 cuda-demo-suite-9-0 cuda-drivers cuda-runtime-9-0 libcuda1-384
  nvidia-384 nvidia-384-dev nvidia-opencl-icd-384
The following NEW packages will be installed:
  libnvidia-compute-460 update-notifier-common
The following packages will be upgraded:
  python3-apt
1 upgraded, 2 newly installed, 8 to remove and 27 not upgraded.
3 not fully installed or removed.
Need to get 0 B/22.1 MB of archives.
After this operation, 268 MB disk space will be freed.
Do you want to continue? [Y/n] y
...
dpkg: warning: files list file for package 'libxcb-sync-dev:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'ubuntu-standard' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'nvidia-opencl-icd-384' missing; assuming package has no files currently installed
(Reading database ... 618606 files and directories currently installed.)
Preparing to unpack .../python3-apt_1.1.0~beta1ubuntu0.16.04.11_amd64.deb ...
/var/lib/dpkg/info/python3-apt.prerm: 6: /var/lib/dpkg/info/python3-apt.prerm: py3clean: Too many levels of symbolic links
dpkg: warning: subprocess old pre-removal script returned error exit status 2
dpkg: trying script from the new package instead ...
/var/lib/dpkg/tmp.ci/prerm: 6: /var/lib/dpkg/tmp.ci/prerm: py3clean: Too many levels of symbolic links
dpkg: error processing archive /var/cache/apt/archives/python3-apt_1.1.0~beta1ubuntu0.16.04.11_amd64.deb (--unpack):
 subprocess new pre-removal script returned error exit status 2
/var/lib/dpkg/info/python3-apt.postinst: 6: /var/lib/dpkg/info/python3-apt.postinst: py3compile: Too many levels of symbolic links
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
 /var/cache/apt/archives/python3-apt_1.1.0~beta1ubuntu0.16.04.11_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
ipc@ipc-System-Product-Name:~$ sudo dpkg --configure -a
dpkg: error processing package python3-apt (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Errors were encountered while processing:
 python3-apt
ipc@ipc-System-Product-Name:~$ ^C
ipc@ipc-System-Product-Name:~$ clear
[3;J
ipc@ipc-System-Product-Name:~$ sudo dpkg --configure -a
dpkg: error processing package python3-apt (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Errors were encountered while processing:
 python3-apt
ipc@ipc-System-Product-Name:~$ sudo apt-get purge nvidia*
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'nvidia-325-updates' for glob 'nvidia*'
Note, selecting 'nvidia-346-updates' for glob 'nvidia*'
Note, selecting 'nvidia-driver-binary' for glob 'nvidia*'
Note, selecting 'nvidia-331-dev' for glob 'nvidia*'
Note, selecting 'nvidia-304-updates-dev' for glob 'nvidia*'
Note, selecting 'nvidia-384-dev' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-346-updates' for glob 'nvidia*'
Note, selecting 'nvidia-340-updates-uvm' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-common' for glob 'nvidia*'
Note, selecting 'nvidia-331-updates-uvm' for glob 'nvidia*'
Note, selecting 'nvidia-glx' for glob 'nvidia*'
Note, selecting 'nvidia-cg-toolkit' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-common-410' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-common-418' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-common-430' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-common-440' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-common-450' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-common-455' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-common-460' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-340-updates' for glob 'nvidia*'
Note, selecting 'nvidia' for glob 'nvidia*'
Note, selecting 'nvidia-driver' for glob 'nvidia*'
Note, selecting 'nvidia-modprobe' for glob 'nvidia*'
Note, selecting 'nvidia-texture-tools' for glob 'nvidia*'
Note, selecting 'nvidia-utils' for glob 'nvidia*'
Note, selecting 'nvidia-current-diagnostic' for glob 'nvidia*'
Note, selecting 'nvidia-legacy-340xx-vdpau-driver' for glob 'nvidia*'
Note, selecting 'nvidia-349-updates' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-686-pae' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-304-updates' for glob 'nvidia*'
Note, selecting 'nvidia-310-updates' for glob 'nvidia*'
Note, selecting 'nvidia-331-updates' for glob 'nvidia*'
Note, selecting 'nvidia-352-dev' for glob 'nvidia*'
Note, selecting 'nvidia-vdpau-driver' for glob 'nvidia*'
Note, selecting 'nvidia-fabricmanager-450' for glob 'nvidia*'
Note, selecting 'nvidia-fabricmanager-455' for glob 'nvidia*'
Note, selecting 'nvidia-fabricmanager-460' for glob 'nvidia*'
Note, selecting 'nvidia-346-dev' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-331-updates' for glob 'nvidia*'
Note, selecting 'nvidia-smi' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-361-updates' for glob 'nvidia*'
Note, selecting 'nvidia-313-updates' for glob 'nvidia*'
Note, selecting 'nvidia-334-updates' for glob 'nvidia*'
Note, selecting 'nvidia-utils-410' for glob 'nvidia*'
Note, selecting 'nvidia-utils-418' for glob 'nvidia*'
Note, selecting 'nvidia-utils-430' for glob 'nvidia*'
Note, selecting 'nvidia-utils-440' for glob 'nvidia*'
Note, selecting 'nvidia-utils-450' for glob 'nvidia*'
Note, selecting 'nvidia-utils-455' for glob 'nvidia*'
Note, selecting 'nvidia-utils-460' for glob 'nvidia*'
Note, selecting 'nvidia-331-uvm' for glob 'nvidia*'
Note, selecting 'nvidia-fabricmanager-dev' for glob 'nvidia*'
Note, selecting 'nvidia-prime' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-dkms' for glob 'nvidia*'
Note, selecting 'nvidia-dkms-410' for glob 'nvidia*'
Note, selecting 'nvidia-dkms-418' for glob 'nvidia*'
Note, selecting 'nvidia-dkms-430' for glob 'nvidia*'
Note, selecting 'nvidia-dkms-440' for glob 'nvidia*'
Note, selecting 'nvidia-dkms-450' for glob 'nvidia*'
Note, selecting 'nvidia-dkms-455' for glob 'nvidia*'
Note, selecting 'nvidia-dkms-460' for glob 'nvidia*'
Note, selecting 'nvidia-current-updates' for glob 'nvidia*'
Note, selecting 'nvidia-340-dev' for glob 'nvidia*'
Note, selecting 'nvidia-fabricmanager' for glob 'nvidia*'
Note, selecting 'nvidia-nsight' for glob 'nvidia*'
Note, selecting 'nvidia-common' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-346-updates' for glob 'nvidia*'
Note, selecting 'nvidia-352-updates' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-amd64' for glob 'nvidia*'
Note, selecting 'nvidia-headless-no-dkms-410' for glob 'nvidia*'
Note, selecting 'nvidia-headless-no-dkms-418' for glob 'nvidia*'
Note, selecting 'nvidia-headless-no-dkms-430' for glob 'nvidia*'
Note, selecting 'nvidia-headless-no-dkms-440' for glob 'nvidia*'
Note, selecting 'nvidia-headless-no-dkms-450' for glob 'nvidia*'
Note, selecting 'nvidia-headless-no-dkms-455' for glob 'nvidia*'
Note, selecting 'nvidia-headless-no-dkms-460' for glob 'nvidia*'
Note, selecting 'nvidia-current-dev' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-352-updates' for glob 'nvidia*'
Note, selecting 'nvidia-440-dev' for glob 'nvidia*'
Note, selecting 'nvidia-compute-utils-410' for glob 'nvidia*'
Note, selecting 'nvidia-compute-utils-418' for glob 'nvidia*'
Note, selecting 'nvidia-compute-utils-430' for glob 'nvidia*'
Note, selecting 'nvidia-compute-utils-440' for glob 'nvidia*'
Note, selecting 'nvidia-compute-utils-450' for glob 'nvidia*'
Note, selecting 'nvidia-compute-utils-455' for glob 'nvidia*'
Note, selecting 'nvidia-compute-utils-460' for glob 'nvidia*'
Note, selecting 'nvidia-355-updates' for glob 'nvidia*'
Note, selecting 'nvidia-375-dev' for glob 'nvidia*'
Note, selecting 'nvidia-current' for glob 'nvidia*'
Note, selecting 'nvidia-profiler' for glob 'nvidia*'
Note, selecting 'nvidia-337-updates' for glob 'nvidia*'
Note, selecting 'nvidia-367-dev' for glob 'nvidia*'
Note, selecting 'nvidia-driver-410' for glob 'nvidia*'
Note, selecting 'nvidia-driver-418' for glob 'nvidia*'
Note, selecting 'nvidia-driver-430' for glob 'nvidia*'
Note, selecting 'nvidia-driver-440' for glob 'nvidia*'
Note, selecting 'nvidia-driver-450' for glob 'nvidia*'
Note, selecting 'nvidia-driver-455' for glob 'nvidia*'
Note, selecting 'nvidia-driver-460' for glob 'nvidia*'
Note, selecting 'nvidia-cuda-toolkit' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-source' for glob 'nvidia*'
Note, selecting 'nvidia-340-updates-dev' for glob 'nvidia*'
Note, selecting 'nvidia-319-updates' for glob 'nvidia*'
Note, selecting 'nvidia-fabricmanager-dev-450' for glob 'nvidia*'
Note, selecting 'nvidia-fabricmanager-dev-455' for glob 'nvidia*'
Note, selecting 'nvidia-fabricmanager-dev-460' for glob 'nvidia*'
Note, selecting 'nvidia-304-dev' for glob 'nvidia*'
Note, selecting 'nvidia-331-updates-dev' for glob 'nvidia*'
Note, selecting 'nvidia-visual-profiler' for glob 'nvidia*'
Note, selecting 'nvidia-persistenced' for glob 'nvidia*'
Note, selecting 'nvidia-current-updates-dev' for glob 'nvidia*'
Note, selecting 'nvidia-361-dev' for glob 'nvidia*'
Note, selecting 'nvidia-settings-binary' for glob 'nvidia*'
Note, selecting 'nvidia-361-updates-dev' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-304' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-331' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-340' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-346' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-352' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-361' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-367' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-375' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-384' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-486' for glob 'nvidia*'
Note, selecting 'nvidia-352-updates-dev' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-331-updates' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-352-updates' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-440' for glob 'nvidia*'
Note, selecting 'nvidia-304-updates' for glob 'nvidia*'
Note, selecting 'nvidia-340-uvm' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-304-updates' for glob 'nvidia*'
Note, selecting 'nvidia-headless-410' for glob 'nvidia*'
Note, selecting 'nvidia-headless-418' for glob 'nvidia*'
Note, selecting 'nvidia-headless-430' for glob 'nvidia*'
Note, selecting 'nvidia-headless-440' for glob 'nvidia*'
Note, selecting 'nvidia-headless-450' for glob 'nvidia*'
Note, selecting 'nvidia-headless-455' for glob 'nvidia*'
Note, selecting 'nvidia-headless-460' for glob 'nvidia*'
Note, selecting 'nvidia-cuda-dev' for glob 'nvidia*'
Note, selecting 'nvidia-cuda-doc' for glob 'nvidia*'
Note, selecting 'nvidia-340-updates' for glob 'nvidia*'
Note, selecting 'nvidia-361-updates' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-dev' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-dev' for glob 'nvidia*'
Note, selecting 'nvidia-driver-local-repo-ubuntu1604-440.33.01' for glob 'nvidia*'
Note, selecting 'nvidia-cg-dev' for glob 'nvidia*'
Note, selecting 'nvidia-cg-doc' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-340-updates' for glob 'nvidia*'
Note, selecting 'nvidia-libopencl1-361-updates' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-304' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-331' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-340' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-346' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-352' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-361' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-367' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-375' for glob 'nvidia*'
Note, selecting 'nvidia-cuda-gdb' for glob 'nvidia*'
Note, selecting 'nvidia-experimental-304' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-384' for glob 'nvidia*'
Note, selecting 'nvidia-experimental-310' for glob 'nvidia*'
Note, selecting 'nvidia-experimental-313' for glob 'nvidia*'
Note, selecting 'nvidia-experimental-319' for glob 'nvidia*'
Note, selecting 'nvidia-experimental-325' for glob 'nvidia*'
Note, selecting 'nvidia-experimental-331' for glob 'nvidia*'
Note, selecting 'nvidia-experimental-334' for glob 'nvidia*'
Note, selecting 'nvidia-experimental-337' for glob 'nvidia*'
Note, selecting 'nvidia-experimental-340' for glob 'nvidia*'
Note, selecting 'nvidia-experimental-343' for glob 'nvidia*'
Note, selecting 'nvidia-experimental-346' for glob 'nvidia*'
Note, selecting 'nvidia-experimental-349' for glob 'nvidia*'
Note, selecting 'nvidia-experimental-352' for glob 'nvidia*'
Note, selecting 'nvidia-experimental-355' for glob 'nvidia*'
Note, selecting 'nvidia-experimental-304-dev' for glob 'nvidia*'
Note, selecting 'nvidia-343-updates' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd-440' for glob 'nvidia*'
Note, selecting 'nvidia-304' for glob 'nvidia*'
Note, selecting 'nvidia-310' for glob 'nvidia*'
Note, selecting 'nvidia-313' for glob 'nvidia*'
Note, selecting 'nvidia-319' for glob 'nvidia*'
Note, selecting 'nvidia-325' for glob 'nvidia*'
Note, selecting 'nvidia-331' for glob 'nvidia*'
Note, selecting 'nvidia-334' for glob 'nvidia*'
Note, selecting 'nvidia-337' for glob 'nvidia*'
Note, selecting 'nvidia-340' for glob 'nvidia*'
Note, selecting 'nvidia-343' for glob 'nvidia*'
Note, selecting 'nvidia-346' for glob 'nvidia*'
Note, selecting 'nvidia-349' for glob 'nvidia*'
Note, selecting 'nvidia-352' for glob 'nvidia*'
Note, selecting 'nvidia-355' for glob 'nvidia*'
Note, selecting 'nvidia-361' for glob 'nvidia*'
Note, selecting 'nvidia-367' for glob 'nvidia*'
Note, selecting 'nvidia-375' for glob 'nvidia*'
Note, selecting 'nvidia-384' for glob 'nvidia*'
Note, selecting 'nvidia-dkms-kernel' for glob 'nvidia*'
Note, selecting 'nvidia-390' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-source-410' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-source-418' for glob 'nvidia*'
Note, selecting 'nvidia-346-updates-dev' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-source-430' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-source-440' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-source-450' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-source-455' for glob 'nvidia*'
Note, selecting 'nvidia-kernel-source-460' for glob 'nvidia*'
Note, selecting 'nvidia-440' for glob 'nvidia*'
Note, selecting 'nvidia-settings' for glob 'nvidia*'
Note, selecting 'nvidia-opencl-icd' for glob 'nvidia*'
Note, selecting 'nvidia-settings' instead of 'nvidia-settings-binary'
Package 'nvidia-libopencl1-dev' is not installed, so not removed
Package 'nvidia-libopencl1' is not installed, so not removed
Package 'nvidia-vdpau-driver' is not installed, so not removed
Package 'nvidia-legacy-340xx-vdpau-driver' is not installed, so not removed
Package 'nvidia-driver' is not installed, so not removed
Package 'nvidia-glx' is not installed, so not removed

Package 'nvidia-334' is not installed, so not removed
Package 'nvidia-334-updates' is not installed, so not removed
Package 'nvidia-experimental-334' is not installed, so not removed
Package 'nvidia-337' is not installed, so not removed
Package 'nvidia-337-updates' is not installed, so not removed
Package 'nvidia-experimental-337' is not installed, so not removed
Package 'nvidia-experimental-340' is not installed, so not removed
Package 'nvidia-343' is not installed, so not removed
Package 'nvidia-343-updates' is not installed, so not removed
Package 'nvidia-experimental-343' is not installed, so not removed
Package 'nvidia-experimental-346' is not installed, so not removed
Package 'nvidia-349' is not installed, so not removed
Package 'nvidia-349-updates' is not installed, so not removed
Package 'nvidia-experimental-349' is not installed, so not removed
Package 'nvidia-experimental-352' is not installed, so not removed
Package 'nvidia-355' is not installed, so not removed
Package 'nvidia-355-updates' is not installed, so not removed
Package 'nvidia-experimental-355' is not installed, so not removed
Note, selecting 'libnvtt-bin' instead of 'nvidia-texture-tools'
Package 'nvidia-390' is not installed, so not removed
Package 'nvidia-340-updates-uvm' is not installed, so not removed
Package 'nvidia-346' is not installed, so not removed
...
Package 'nvidia-opencl-icd-375' is not installed, so not removed
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 cuda-drivers : Depends: nvidia-384 (>= 384.81)
                Depends: nvidia-384-dev (>= 384.81) but it is not going to be installed
                Depends: nvidia-modprobe (>= 384.81) but it is not going to be installed
                Depends: nvidia-settings (>= 384.81) but it is not going to be installed
                Depends: nvidia-opencl-icd-384 (>= 384.81) but it is not going to be installed
 libcuda1-384 : Depends: nvidia-384 (>= 384.130)
 update-notifier : Depends: update-notifier-common (= 3.168.13) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

我已经尝试了很多答案

$sudo -s -- <<EOF
sudo dpkg --configure -a
sudo apt install -f
sudo apt dist-upgrade
sudo apt autoremove --purge
sudo dpkg -i /var/cache/apt/archives/*.deb
Sudo apt install --reinstall /var/cache/apt/archives/*.deb
sudo apt install pop-desktop
sudo apt-get install update-manager-core
sudo do-release-upgrade -d
sudo reboot
EOF

$sudo dpkg -i --force-overwrite /var/cache/apt/archives/*.deb

$sudo -s -- <<EOF
sudo apt-get autoclean
sudo apt-get update
sudo apt-get upgrade
EOF

但我得到了不同的错误,我也更改了source.list文件。此外,我已从中删除了该包,state并尝试过synaptic

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
97 not fully installed or removed.
Need to get 0 B/5699 kB of archives.
After this operation, 0 B of additional disk space will be used.
dpkg: error processing package python-apt (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
dpkg: error processing package python-attr (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
dpkg: error processing package python-blinker (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
dpkg: error processing package python-bs4 (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
dpkg: error processing package python-idna (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
dpkg: error processing package python-ipaddress (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
dpkg: error processing package python-pyasn1 (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
dpkg: error processing package No apport report written because MaxReports is reached already
             No apport report written because MaxReports is reached already
                                                                           No apport report written because MaxReports is reached already
                                                         No apport report written because MaxReports is reached already
                                       No apport report written because MaxReports is reached already
                     No apport report written because MaxReports is reached already
   python-six (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
dpkg: dependency problems prevent configuration of python-cryptography:
 python-cryptography depends on python-idna; however:
  Package python-idna is not configured yet.
 python-cryptography depends on python-ipaddress; however:
  Package python-ipaddress is not configured yet.
 python-cryptography depends on python-pyasn1 (>= 0.1.8); however:
  Package python-pyasn1 is not configured yet.
 python-cryptography depends on python-six (>= 1.4.1); however:
  Package python-six is not configured yet.
...

dpkg: error processing package apt-xapian-index (--configure):
 dependency problems - leaving unconfigured
dpkg: too many errors, stopping
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 python-apt
 python-attr
 python-blinker
 python-bs4
 python-idna
 python-ipaddress
 python-pyasn1
 python-six
 python-cryptography
 python-dbus
 python-debian
 python-debtagshw
 python-html5lib
 python-httplib2
 python-jwt
 python-lxml
 python-oauthlib
 python-openssl
 python-pyasn1-modules
 python-serial
 python-service-identity
 python-zope.interface
 python-twisted-core
 python-xapian
 python-xdg
 python-piston-mini-client
 software-center-aptdaemon-plugins
 python-defer
 python-aptdaemon
 python-aptdaemon.gtk3widgets
 python-oneconf
 software-center
 python-dirspec
 python-ubuntu-sso-client
 python3
 python3-apt
 ubuntu-drivers-common
 python3-debian
 lsb-release
 python3-distupgrade
 python3-update-manager
 ubuntu-release-upgrader-core
 update-manager-core
 update-notifier-common
 python3-commandnotfound
 ufw
 python3-apport
 apport
 apport-gtk
 python3-xapian1.3
 apt-xapian-index
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

我要做的第一件事就是apt重新开始工作,详情如下:

总结一下答案:

访问http://packages.ubuntu.com,并下载python-minimalpython3-minimalapt软件包,然后使用 dpkg 安装这些软件包。这可能需要几次迭代,因为 dpkg 会抱怨缺少其他依赖项,您必须按正确的顺序下载和安装这些依赖项。

一般来说,大多数 Python 损坏或丢失的用户会发现,只需备份数据并进行全新安装就会更快、更容易。

相关内容