由于 python3-minimal 和 language-gnome-selector 无法安装任何东西

由于 python3-minimal 和 language-gnome-selector 无法安装任何东西

我正在尝试在我的环境中安装 python3(和 python2),但我一直收到以下问题:

sudo apt-get install python3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3 is already the newest version (3.10.6-1~22.04).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python3-minimal (3.10.6-1~22.04) ...
/var/lib/dpkg/info/python3-minimal.postinst: 5: py3compile: not found
dpkg: error processing package python3-minimal (--configure):
 installed python3-minimal package post-installation script subprocess returned error exit status 127
Setting up language-selector-gnome (0.219) ...
/var/lib/dpkg/info/language-selector-gnome.postinst: 6: py3compile: not found
dpkg: error processing package language-selector-gnome (--configure):
 installed language-selector-gnome package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 python3-minimal
 language-selector-gnome
E: Sub-process /usr/bin/dpkg returned an error code (1)

我尝试用不同的方法修复这个问题,但每次都遇到同样的问题。感谢您的帮助。

编辑:我运行了命令

sudo apt remove python3

尝试删除 python3 但出现以下错误:

The following NEW packages will be installed:
  libqt5gui5-gles libqt5quick5-gles
0 upgraded, 2 newly installed, 217 to remove and 0 not upgraded.
3 not fully installed or removed.
Need to get 0 B/5,427 kB of archives.
After this operation, 276 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 261970 files and directories currently installed.)
    Removing language-selector-gnome (0.219) ...
    /var/lib/dpkg/info/language-selector-gnome.prerm: 6: py3clean: not found
    dpkg: error processing package language-selector-gnome (--remove):
     installed language-selector-gnome package pre-removal script subprocess returne
    d error exit status 127
    /var/lib/dpkg/info/language-selector-gnome.postinst: 6: py3compile: not found
    dpkg: error while cleaning up:
     installed language-selector-gnome package post-installation script subprocess r
    eturned error exit status 127
    Removing python3-commandnotfound (22.04.0) ...
    /var/lib/dpkg/info/python3-commandnotfound.prerm: 6: py3clean: not found
    dpkg: error processing package python3-commandnotfound (--remove):
     installed python3-commandnotfound package pre-removal script subprocess returne
    d error exit status 127
    dpkg: too many errors, stopping
    Errors were encountered while processing:
     language-selector-gnome
     python3-commandnotfound
    Processing was halted because there were too many errors.
    E: Sub-process /usr/bin/dpkg returned an error code (1)

编辑 2:尝试通过以下方式安装 python3.10-minimal:

sudo apt-get install python3.10-minimal

并收到以下错误:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3.10-minimal is already the newest version (3.10.6-1~22.04.2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
3 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python3-commandnotfound (22.04.0) ...
/var/lib/dpkg/info/python3-commandnotfound.postinst: 6: py3compile: not found
dpkg: error processing package python3-commandnotfound (--configure):
 installed python3-commandnotfound package post-installation script subprocess returned error exit status 127
Setting up python3-minimal (3.10.6-1~22.04) ...
/var/lib/dpkg/info/python3-minimal.postinst: 5: py3compile: not found
dpkg: error processing package python3-minimal (--configure):
 installed python3-minimal package post-installation script subprocess returned error exit status 127
Setting up language-selector-gnome (0.219) ...
/var/lib/dpkg/info/language-selector-gnome.postinst: 6: py3compile: not found
dpkg: error processing package language-selector-gnome (--configure):
 installed language-selector-gnome package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 python3-commandnotfound
 python3-minimal
 language-selector-gnome
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

当你逐行阅读原始错误消息时,你会发现这些行。所有其他错误——不管怎样——都是从这个原始错误中产生的:

Setting up python3-minimal (3.10.6-1~22.04) ...
/var/lib/dpkg/info/python3-minimal.postinst: 5: py3compile: not found

这里的关键是py3compile: not found。该py3compile模块由 22.04 版软件包提供python3.10-minimal

  • 软件包python3.xx-minimal名称随 Ubuntu 的不同版本而变化。通过查看依赖项找到适合您的 Ubuntu 版本的软件包python3-minimal

修复该问题需要两个步骤。

  1. 安装(或重新安装)你的python3.xx-minimal软件包
    sudo apt install python3.10-minimal
    sudo apt install --reinstall python3.10-minimal

  2. 将新安装的软件包的 apt-marking 从 更改automanual
    sudo apt-mark auto python3.10-minimal

相关内容