当前位置:   article > 正文

ubuntu下dpkg: Error processing package或Sub-process /usr/bin/dpkg returned an error code (1)解决方法_dpkg: error processing package python3

dpkg: error processing package python3

遇到问题

今天在wsl2下ubuntu18中重装python3和pip结果遇到问题

执行如下命令

sudo apt update # 这一步正常
 sudo apt install python3-pip # 这一步出现问题
  • 1
  • 2

产生如下问题

Setting up python3-crypto (2.6.1-8ubuntu2) ...
/var/lib/dpkg/info/python3-crypto.postinst: 6: /var/lib/dpkg/info/python3-crypto.postinst: py3compile: not found
dpkg: error processing package python3-crypto (--configure):
 installed python3-crypto package post-installation script subprocess returned error exit status 127
Setting up python3-xdg (0.25-4ubuntu1.1) ...
/var/lib/dpkg/info/python3-xdg.postinst: 6: /var/lib/dpkg/info/python3-xdg.postinst: py3compile: not found
dpkg: error processing package python3-xdg (--configure):
 installed python3-xdg package post-installation script subprocess returned error exit status 127
dpkg: dependency problems prevent configuration of python3-keyrings.alt:
 python3-keyrings.alt depends on python3-crypto; however:
  Package python3-crypto is not configured yet.

dpkg: error processing package python3-keyrings.alt (--configure):
 dependency problems - leaving unconfigured
Setting up python3-wheel (0.30.0-0.2) ...
/var/lib/dpkg/info/python3-wheel.postinst: 6: /var/lib/dpkg/info/python3-wheel.postinst: py3compile: not found
dpkg: error processing package python3-wheel (--configure):
 installed python3-wheel package post-installation script subprocess returned error exit status 127
Setting up libpython3.6-dev:amd64 (3.6.9-1~18.04ubuntu1.7) ...
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          No apport report written because MaxReports is reached already
                                                                                                                                                                        Setting up python3.6-dev (3.6.9-1~18.04ubuntu1.7) ...
Setting up python3-lib2to3 (3.6.9-1~18.04) ...
Setting up python3-secretstorage (2.3.1-2) ...
/var/lib/dpkg/info/python3-secretstorage.postinst: 6: /var/lib/dpkg/info/python3-secretstorage.postinst: py3compile: not found
dpkg: error processing package python3-secretstorage (--configure):
 installed python3-secretstorage package post-installation script subprocess returned error exit status 127
No apport report written because MaxReports is reached already
                                                              Setting up python3-distutils (3.6.9-1~18.04) ...
Setting up libpython3-dev:amd64 (3.6.7-1~18.04) ...
dpkg: dependency problems prevent configuration of python3-keyring:
 python3-keyring depends on python3-secretstorage; however:
  Package python3-secretstorage is not configured yet.

dpkg: error processing package python3-keyring (--configure):
 dependency problems - leaving unconfigured
Setting up python3-pip (9.0.1-2.3~ubuntu1.18.04.5) ...
No apport report written because MaxReports is reached already
                                                              /var/lib/dpkg/info/python3-pip.postinst: 6: /var/lib/dpkg/info/python3-pip.postinst: py3compile: not found
dpkg: error processing package python3-pip (--configure):
 installed python3-pip package post-installation script subprocess returned error exit status 127
No apport report written because MaxReports is reached already
                                                              Setting up python3-setuptools (39.0.1-2) ...
/var/lib/dpkg/info/python3-setuptools.postinst: 6: /var/lib/dpkg/info/python3-setuptools.postinst: py3compile: not found
dpkg: error processing package python3-setuptools (--configure):
 installed python3-setuptools package post-installation script subprocess returned error exit status 127
Setting up dh-python (3.20180325ubuntu2) ...
No apport report written because MaxReports is reached already
                                                              /var/lib/dpkg/info/dh-python.postinst: 6: /var/lib/dpkg/info/dh-python.postinst: py3compile: not found
dpkg: error processing package dh-python (--configure):
 installed dh-python package post-installation script subprocess returned error exit status 127
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of python3-dev:
 python3-dev depends on dh-python; however:
  Package dh-python is not configured yet.

No apport report written because MaxReports is reached already
                                                              dpkg: error processing package python3-dev (--configure):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Errors were encountered while processing:
 python3-crypto
 python3-xdg
 python3-keyrings.alt
 python3-wheel
 python3-secretstorage
 python3-keyring
 python3-pip
 python3-setuptools
 dh-python
 python3-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72

解决方法

搜索这个问题

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

stackoverflow上找到一篇解答:Sub-process dpkg returned an error code (1),下面的答主是删除了info文件夹,然后重新创建了info文件夹解决了这个问题。

具体步骤如下:

cd /var/lib/dpkg/  # 进入这个路径
sudo mv info/ info_bak  # 将info文件夹改名为info_bak
sudo mkdir info # 新建info文件夹
# 如下两步:会重新往info中写入一些文件
sudo apt-get update # 升级一下
sudo apt-get -f install # install一下

sudo mv info info_bak/ # 将info移动到info_bak
sudo rm -rf info  # 删掉自己之前创建的info文件夹
sudo mv info_bak info # 将info_bak 重命名为info
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

关于mv指令可以参考菜鸟教程的文章:https://www.runoob.com/linux/linux-comm-mv.html

现在再安装pip3不会出现问题

sudo apt update
sudo apt install python3-pip
  • 1
  • 2

具体步骤操作结果如下:

azheng@lishizheng:/mnt/e/shizheng_coding$ cd /var/lib/dpkg/
azheng@lishizheng:/var/lib/dpkg$ sudo mv info/ info_bak
azheng@lishizheng:/var/lib/dpkg$ sudo mkdir info
azheng@lishizheng:/var/lib/dpkg$ sudo apt-get update
Hit:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic InRelease
Hit:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates InRelease
Hit:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports InRelease
Hit:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security InRelease
Hit:5 http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic InRelease
Hit:6 https://download.docker.com/linux/ubuntu bionic InRelease
Reading package lists... Done
azheng@lishizheng:/var/lib/dpkg$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
10 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up python3-crypto (2.6.1-8ubuntu2) ...
Setting up python3-xdg (0.25-4ubuntu1.1) ...
Setting up python3-keyrings.alt (3.0-1) ...
Setting up python3-wheel (0.30.0-0.2) ...
Setting up python3-pip (9.0.1-2.3~ubuntu1.18.04.5) ...
Setting up python3-setuptools (39.0.1-2) ...
Setting up python3-secretstorage (2.3.1-2) ...
Setting up dh-python (3.20180325ubuntu2) ...
Setting up python3-keyring (10.6.0-1) ...
Setting up python3-dev (3.6.7-1~18.04) ...
W: APT had planned for dpkg to do more than it reported back (9 vs 31).
   Affected packages: dh-python:amd64 python3-crypto:amd64 python3-pip:amd64 python3-secretstorage:amd64 python3-setuptools:amd64 python3-wheel:amd64 python3-xdg:amd64
azheng@lishizheng:/var/lib/dpkg$ sudo mv info info_bak/
azheng@lishizheng:/var/lib/dpkg$ sudo rm -rf info
azheng@lishizheng:/var/lib/dpkg$ sudo mv info_bak info
azheng@lishizheng:/var/lib/dpkg$ sudo apt-get update
Hit:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic InRelease
Hit:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates InRelease
Hit:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports InRelease
Hit:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security InRelease
Hit:5 http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic InRelease
Hit:6 https://download.docker.com/linux/ubuntu bionic InRelease
Reading package lists... Done
azheng@lishizheng:/var/lib/dpkg$ sudo apt install python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-pip is already the newest version (9.0.1-2.3~ubuntu1.18.04.5).
0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
azheng@lishizheng:/var/lib/dpkg$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48

另外,下面参考中也是同样的处理思路,笔者也是对其进行了参考,对其表示感谢。

参考

解决apt-get安装中的E: Sub-process /usr/bin/dpkg returned an error code (1)问题

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/88682?site
推荐阅读
相关标签
  

闽ICP备14008679号