E: Sub-process /usr/bin/dpkg returned an error code (1)

问题:

root@jdh-Precision-7920-Tower:~# apt-get install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 python-pip : Depends: python-pip-whl (= 9.0.1-2.3~ubuntu1.18.04.4) but 8.1.1-2ubuntu0.6 is to be installed
              Recommends: python-all-dev (>= 2.6) but it is not going to be installed
              Recommends: python-setuptools but it is not going to be installed
              Recommends: python-wheel but it is not going to be installed
 python3-dev : Depends: python3-distutils (>= 3.6.7-1~) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
root@jdh-Precision-7920-Tower:~# 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:
  libpython3.5-dev python3.5 python3.5-dev python3.5-minimal
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  python3-distutils python3-lib2to3
The following NEW packages will be installed:
  python3-distutils python3-lib2to3
0 upgraded, 2 newly installed, 0 to remove and 795 not upgraded.
16 not fully installed or removed.
Need to get 222 kB of archives.
After this operation, 3143 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-lib2to3 all 3.6.9-1~18.04 [77.4 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-distutils all 3.6.9-1~18.04 [144 kB]
Fetched 222 kB in 2s (117 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 73324 files and directories currently installed.)
Preparing to unpack .../python3-lib2to3_3.6.9-1~18.04_all.deb ...
Unpacking python3-lib2to3 (3.6.9-1~18.04) ...
dpkg: error processing archive /var/cache/apt/archives/python3-lib2to3_3.6.9-1~18.04_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.6/lib2to3/Grammar.txt', which is also in package libpython3.6-stdlib:amd64 3.6.12-1+xenial1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Preparing to unpack .../python3-distutils_3.6.9-1~18.04_all.deb ...
Unpacking python3-distutils (3.6.9-1~18.04) ...
dpkg: error processing archive /var/cache/apt/archives/python3-distutils_3.6.9-1~18.04_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.6/distutils/README', which is also in package libpython3.6-stdlib:amd64 3.6.12-1+xenial1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/python3-lib2to3_3.6.9-1~18.04_all.deb
 /var/cache/apt/archives/python3-distutils_3.6.9-1~18.04_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

解决

#将info文件夹更名
root@jdh-Precision-7920-Tower:~# mv /var/lib/dpkg/info /var/lib/dpkg/info.bk

#新建一个info文件夹
root@jdh-Precision-7920-Tower:~# mkdir /var/lib/dpkg/info

#安装修复
root@jdh-Precision-7920-Tower:~# apt-get update
Hit:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease
Hit:3 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu xenial InRelease
Hit:4 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:5 http://cn.archive.ubuntu.com/ubuntu bionic InRelease
Hit:6 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:7 http://cn.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:8 http://cn.archive.ubuntu.com/ubuntu bionic-security InRelease
Hit:9 http://cn.archive.ubuntu.com/ubuntu bionic-proposed InRelease
Ign:10 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  InRelease
Ign:11 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64  InRelease
Hit:12 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Release
Hit:14 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64  Release
Reading package lists... Done

root@jdh-Precision-7920-Tower:~# apt-get install -f

#执行完上一步操作后,在info文件夹下生成一些文件,将这些文件全部转移到info.bk 文件夹下
root@jdh-Precision-7920-Tower:~# mv /var/lib/dpkg/info/* /var/lib/dpkg/info.bk

#把自己新建的info文件夹删掉
root@jdh-Precision-7920-Tower:~# rm -rf /var/lib/dpkg/info

#恢复原有info文件夹,修改名字
root@jdh-Precision-7920-Tower:~# mv /var/lib/dpkg/info.bk /var/lib/dpkg/info

之后安装

root@jdh-Precision-7920-Tower:~# apt-get install python3-pip

 

你可能感兴趣的:(linux,ubuntu)