IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 系统运维 -> ubuntu下dpkg: Error processing package或Sub-process /usr/bin/dpkg returned an error code (1)解决方法 -> 正文阅读

[系统运维]ubuntu下dpkg: Error processing package或Sub-process /usr/bin/dpkg returned an error code (1)解决方法

遇到问题

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

执行如下命令

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

产生如下问题

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)

解决方法

搜索这个问题

Sub-process /usr/bin/dpkg returned an error code (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

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

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

sudo apt update
sudo apt install python3-pip

具体步骤操作结果如下:

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$

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

参考

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

  系统运维 最新文章
配置小型公司网络WLAN基本业务(AC通过三层
如何在交付运维过程中建立风险底线意识,提
快速传输大文件,怎么通过网络传大文件给对
从游戏服务端角度分析移动同步(状态同步)
MySQL使用MyCat实现分库分表
如何用DWDM射频光纤技术实现200公里外的站点
国内顺畅下载k8s.gcr.io的镜像
自动化测试appium
ctfshow ssrf
Linux操作系统学习之实用指令(Centos7/8均
上一篇文章      下一篇文章      查看所有文章
加:2022-05-05 12:01:58  更:2022-05-05 12:03:09 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/15 17:35:50-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码