AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1040684
Accepted
Oussema
Oussema
Asked: 2018-05-27 12:53:46 +0800 CST2018-05-27 12:53:46 +0800 CST 2018-05-27 12:53:46 +0800 CST

我在 18.04 LTS 上遇到包管理器问题

  • 772

首先,我相信我应该说我本周早些时候刚刚安装了 Ubuntu 18.04 LTS,所以我基本上什么都不知道。
我今天正在安装python3 idle并且遇到了一个错误:

dpkg: error processing package linux-modules-4.15.0-22-generic (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          dpkg: dependency problems prevent configuration of linux-image-4.15.0-22-generic:
 linux-image-4.15.0-22-generic depends on linux-modules-4.15.0-22-generic; however:
  Package linux-modules-4.15.0-22-generic is not configured yet.

dpkg: error processing package linux-image-4.15.0-22-generic (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.27-3ubuntu1) ...
dpkg: dependency problems prevent configuration of linux-modules-extra-4.15.0-22-generic:
 linux-modules-extra-4.15.0-22-generic depends on linux-image-4.15.0-22-generic | linux-image-unsigned-4.15.0-22-generic; however:
  Package linux-image-4.15.0-22-generic is not configured yet.
  Package linux-image-unsigned-4.15.0-22-generic is not installed.

dpkg: error processing package linux-modules-extra-4.15.0-22-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Processing triggers for man-db (2.8.3-2) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1) ...
Setting up libtcl8.6:amd64 (8.6.8+dfsg-3) ...
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-4.15.0-22-generic; however:
  Package linux-image-4.15.0-22-generic is not configured yet.
 linux-image-generic depends on linux-modules-extra-4.15.0-22-generic; however:
  Package linux-modules-extra-4.15.0-22-generic is not configured yet.

dpkg: error processing package linux-image-generic (--configure):
 dependency problems - leaving unconfigured
Setting up libtk8.6:amd64 (8.6.8-4) ...
No apport report written because MaxReports is reached already
                                                              Setting up tk8.6-blt2.5 (2.5.3+dfsg-4) ...
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 4.15.0.22.23); however:
  Package linux-image-generic is not configured yet.

dpkg: error processing package linux-generic (--configure):
 dependency problems - leaving unconfigured
Setting up blt (2.5.3+dfsg-4) ...
No apport report written because MaxReports is reached already
                                                              Setting up python3-tk:amd64 (3.6.5-3) ...
Setting up idle-python3.6 (3.6.5-3) ...
Setting up idle (3.6.5-3) ...
Setting up idle3 (3.6.5-3) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Errors were encountered while processing:
 linux-modules-4.15.0-22-generic
 linux-image-4.15.0-22-generic
 linux-modules-extra-4.15.0-22-generic
 linux-image-generic
 linux-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

所以我Sudo apt-get upgrade认为这只是升级linux模块,我得到了同样的错误信息。我在网上查找错误消息,发现这篇帖子具有相同的错误消息。所以我首先运行了询问者使用的命令:sudo apt-get install -f并收到了以下错误消息:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
5 not fully installed or removed.
Need to get 0 B/12.9 MB of archives.
After this operation, 0 B of additional disk space will be used.
dpkg: error processing package linux-modules-4.15.0-22-generic (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
dpkg: dependency problems prevent configuration of linux-image-4.15.0-22-generic:
 linux-image-4.15.0-22-generic depends on linux-modules-4.15.0-22-generic; however:
  Package linux-modules-4.15.0-22-generic is not configured yet.

dpkg: error processing package linux-image-4.15.0-22-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          No apport report written because the error message indicates its a followup error from a previous failure.
                                            dpkg: dependency problems prevent configuration of linux-modules-extra-4.15.0-22-generic:
 linux-modules-extra-4.15.0-22-generic depends on linux-image-4.15.0-22-generic | linux-image-unsigned-4.15.0-22-generic; however:
  Package linux-image-4.15.0-22-generic is not configured yet.
  Package linux-image-unsigned-4.15.0-22-generic is not installed.

dpkg: error processing package linux-modules-extra-4.15.0-22-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-4.15.0-22-generic; however:
  Package linux-image-4.15.0-22-generic is not configured yet.
 linux-image-generic depends on linux-modules-extra-4.15.0-22-generic; however:
  Package linux-modules-extra-4.15.0-22-generic is not configured yet.

dpkg: error processing package linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-genNo apport report written because MaxReports is reached already
                                                                                                                          No apport report written because MaxReports is reached already
                eric:
 linux-generic depends on linux-image-generic (= 4.15.0.22.23); however:
  Package linux-image-generic is not configured yet.

dpkg: error processing package linux-generic (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-modules-4.15.0-22-generic
 linux-image-4.15.0-22-generic
 linux-modules-extra-4.15.0-22-generic
 linux-image-generic
 linux-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

我的理解与第一个有点不同,第一个说包没有配置,第二个说我应该重新安装它,因为它在配置之前处于错误状态。它给出了与提问者几乎相同的错误消息。所以我尝试了接受的答案中提到的步骤。我运行了这个命令sudo rm /etc/apt/sources.list,然后运行了这个命令,sudo software-properties-gtk我收到了这个错误消息:

WARNING:root:could not open file '/etc/apt/sources.list'

WARNING:root:could not open file '/etc/apt/sources.list'

所以我再次编写了第二个命令,它打开了 software-properties-gtk 并将其写入终端:

 Gtk-Message: 20:43:48.389: GtkDialog mapped without a transient parent. This is discouraged.

所以我使用了这些设置。我点击了Revert,什么也没发生。我再次击中它,仍然没有发生任何事情。所以,我点击关闭并收到此错误消息/通知。我意识到我无法按照该教程进行操作,因为他只是清除了 chrome 而我无法清除 linux 模块。所以,我重新运行sudo apt-get -f install,现在它显示了一条更短的错误消息:

    Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: The package linux-modules-4.15.0-22-generic needs to be reinstalled, but I can't find an archive for it. 

我试过sudo apt-get clean了,终端上什么也没有显示,然后我尝试使用我在这篇文章中看到的这个命令:sudo apt-get install --reinstall linux-modules-4.15.0-22-generic我不知道这是否是要重新安装的包的名称,但值得一试。我得到了同样的错误信息。

我弄坏了什么吗?我需要重新格式化我的系统吗?

编辑:输出ls -la /etc/apt/sources.list是-rw-r--r-- 1 root root 84 May 26 20:43 /etc/apt/sources.list

的输出uname -a是Linux Oussema 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

package-management upgrade dpkg apt
  • 3 3 个回答
  • 20722 Views

3 个回答

  • Voted
  1. Best Answer
    Videonauth
    2018-05-28T00:25:59+08:002018-05-28T00:25:59+08:00

    从评论中我可以读到你已经清理了你的 sources.list 文件,所以让我们首先通过将以下块复制到你的终端来解决这个问题:

    sudo su
    cat > /etc/apt/sources.list << "EOF"
    deb http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu bionic-backports main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu bionic-backports main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
    #deb http://archive.ubuntu.com/ubuntu bionic-proposed main restricted universe multiverse
    #deb-src http://archive.ubuntu.com/ubuntu bionic-proposed main restricted universe multiverse
    deb http://archive.canonical.com/ubuntu bionic partner
    deb-src http://archive.canonical.com/ubuntu bionic partner
    EOF
    exit
    

    现在我们可以开始修复您的安装,它似乎最终处于一种奇怪的状态。

    在运行更新以更新正确的包档案后,首先删除可移动包:

    sudo apt update
    sudo apt autoremove --purge
    

    到目前为止,这应该删除所有可移动的包,除了那些设法弄乱的包,然后我们可以通过安装它然后正确地删除它来删除它:

    cd /var/cache/apt/archives
    sudo dpkg -i linux-modules-4.15.0-22-generic_4.15.0-22.24_amd64.deb
    sudo dpkg -r linux-modules-4.15.0-22-generic_4.15.0-22.24_amd64.deb
    

    现在通过运行清理档案:

    sudo apt clean
    

    现在我们可以在运行完整的更新过程后正确重新安装软件包:

    sudo apt update
    sudo apt dist-upgrade
    

    使用以下行:

    sudo apt install --reinstall linux-generic
    

    这应该已将您的系统再次修复为完整的工作状态。玩得开心,欢迎来到 Linux 社区。

    • 8
  2. jerryboy
    2021-07-21T00:05:28+08:002021-07-21T00:05:28+08:00

    如果上述所有解决方案都不起作用并且在执行“sudo apt autoremove --purge”或大多数与“sudo dpkg --configure -a”类似的apt或dpkg相关命令时遇到问题,并且以下原因粘贴确切的真实场景问题: >

        sudo dpkg --configure -a
        Setting up linux-image-4.15.0-143-generic (4.15.0-143.147) ...
        dpkg (subprocess): unable to execute installed linux-image-4.15.0-143- 
        generic package post-installation script (/var/lib/dpkg/info/linux-image- 
        4.15.0-143-generic.postinst): Permission denied
        dpkg: error processing package linux-image-4.15.0-143-generic (--configure):
        installed linux-image-4.15.0-143-generic package post-installation script 
        subprocess returned error exit status 2
        Errors were encountered while processing:
        linux-image-4.15.0-143-generic
    

    即使在给予完全许可后拒绝使用

        sudo chmod +x /var/lib/dpkg/info/linux-image-4.15.0-143-generic.postinst
    
        or
        cd /var/lib/dpkg/info/
        ls -lrth //Check the existing permission then change either full or only for root access     
        sudo chmod -R +755 /var/lib/dpkg/info/
    

    即使那样仍然面临许可被拒绝的问题,而不是许可问题,因为即使由于 grub 问题而给予许可,请遵循以下步骤

        "CAUTION:>After taking proper checkpoint or snapshot of data to be in safe side as we 
        are reinstalling bootloader if reboot happens by mistake without proper 
        bootloader the vm becomes useless until data_mountpoint is present for all 
        configuration file also stop replication if present to avoid copying to 
        replica also proper internet access to fetch new bootloader".
    

    执行以下操作:>

        apt-get purge grub-pc grub-common //This will purge the current bootloader setup new or update linux-image-*-generic and update-initramfs by generating /boot/initrd.img-*-generic  if menu.lst not found eventhough present in the directory is found do the following 
    

    (如果没有找到任何问题 menu.lst)

        touch /boot/grub/menu.lst
        apt-get purge grub-pc grub-common //Use the latest maintainer version to override the menu.lst it will make appropriate latest menu.lst changes if asked for in purge itself it would be mostly asked at "apt-get install grub-pc grub-common" as it finds multiple menu.lst will ask for compare but choosing maintainer version overide the files and will update with latest.
    

    否则继续以下操作:>

        rm -r /etc/grub.d/ //Check if grub is present if present will be removed mostly will be removed using purge and should show no files to remove or file doesn't exist 
    

    如果提示无法选择需要安装引导加载程序的位置,请安装维护者版本继续不选择磁盘如果使用 scsi 磁盘 sd(a,b,c) 分区磁盘带有 1,2,3 附加的 gui 将提示警告如果使用 HDD,则内部的分区数 hd(a,b,c) 分区磁盘带有 1,2,3 附加在 ex:hda1,hda2,hdb1 中的分区数

        apt-get install grub-pc grub-common
    

    sda 或 hda 这将安装在为引导分配的磁盘的主分区或根分区中。

        grub-install /dev/sda
    

    如果更新没有问题,请检查以下命令,您已获得最新的引导加载程序,并且与更新相关的所有问题都将被删除,apt 和 dpkg 命令将正常工作。

        update-grub
    
    • 1
  3. Ben Molloy
    2019-05-17T04:58:14+08:002019-05-17T04:58:14+08:00

    我已经用这个图像的两个不同版本两次遇到这个问题。在这里查看我的修复:https ://askubuntu.com/a/1141915/954416

    在进行了 apt update 和 apt upgrade 之后,我今天在两台不同的机器上遇到了这个问题,除了我的是针对 linux-image-4.15.0-48-generic 的。(Ubuntu 18.04.2)

    我的修复是这样的(在两台机器上复制):

    sudo rm /var/lib/dpkg/info/linux-image-4.15.0-48-generic.postinst
    sudo dpkg --configure -a
    sudo apt-get update
    

    然后重新安装软件包:

    sudo apt install linux-image-4.15.0-48-generic
    

    这会将包设置为手动安装并替换 *.postinst 文件。

    • 0

相关问题

  • 如何回滚到 PHP 5.2?

  • 包管理器之间有什么区别?

  • 从 8.04 LTS 升级到 10.04 LTS 的体验?

  • 分销升级的合理途径

  • 在不使用标准升级系统的情况下升级有哪些替代方案?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve