Ubuntu 20.04 /var/lib/dpkg/info/software-properties-common.postinst: 6: py3compile: 未找到

Ubuntu 20.04 /var/lib/dpkg/info/software-properties-common.postinst: 6: py3compile: 未找到

当我尝试通过运行以下命令进行升级时:

sudo apt-get upgrade

我收到错误和以下输出:

Reading package lists... Done

Building dependency tree  
     
Reading state information... Done

Calculating upgrade... Done

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 software-properties-common (0.99.9.8) ...

/var/lib/dpkg/info/software-properties-common.postinst: 6:
py3compile: not found

dpkg: error processing package software-properties-common (--configure):

 installed software-properties-common package post-installation script subprocess returned error exit status 127
Setting up python3-minimal (3.8.2-0ubuntu2) ...

/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

dpkg: dependency problems prevent configuration of software-properties-gtk:
 software-properties-gtk depends on software-properties-common; however:
  Package software-properties-common is not configured yet.

dpkg: error processing package software-properties-gtk (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Errors were encountered while processing:
 software-properties-common
 python3-minimal
 software-properties-gtk
E: Sub-process /usr/bin/dpkg returned an error code (1)

的输出which python python3为:

/usr/bin/python

的输出ls -l /usr/bin/python*为:

lrwxrwxrwx 1 root root       7 Apr 15  2020 /usr/bin/python -> python2

lrwxrwxrwx 1 root root       9 Mar 13  2020 /usr/bin/python2 -> python2.7

-rwxr-xr-x 1 root root 3674216 Mar  8  2021 /usr/bin/python2.7
lrwxrwxrwx 1 root root       9 Jul  1 10:56 /usr/bin/python3 -> python3.8

lrwxrwxrwx 1 root root      33 Mar 15 17:52 /usr/bin/python3.8-config -> x86_64-linux-gnu-python3.8-config

lrwxrwxrwx 1 root root      16 Mar 13  2020 /usr/bin/python3-config -> python3.8-config

的输出sudo apt install python-is-python3为:

Package python-is-python3 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only available from another source However the following packages replace it: python-is-python2
E: Package 'python-is-python3' has no installation candidate

然后我按照以下步骤恢复到原始存储库这个答案然后再次运行,sudo apt install python-is-python3输出结果如下:

Reading package lists... Done

Building dependency tree    
   
Reading state information... Done

The following packages were automatically installed and are no longer required:

  libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib linux-headers-5.13.0-48-generic linux-hwe-5.13-headers-5.13.0-48 linux-image-5.13.0-48-generic linux-modules-5.13.0-48-generic
  linux-modules-extra-5.13.0-48-generic python2 python2-minimal python2.7 python2.7-minimal

Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  ubuntu-advantage-tools
The following packages will be REMOVED:
  python-is-python2
The following NEW packages will be installed:
  python-is-python3

The following packages will be upgraded:
  ubuntu-advantage-tools

1 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.

4 not fully installed or removed.

Need to get 879 kB of archives.

After this operation, 21.5 kB of additional disk space will be used.

Do you want to continue? [Y/n] y

Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 ubuntu-advantage-tools amd64 27.9~20.04.1 [876 kB]

Get:2 http://archive.ubuntu.com/ubuntu foca
l/main amd64 python-is-python3 all 3.8.2-4 [2,364 B]

Fetched 879 kB in 2s (361 kB/s)       
        
Preconfiguring packages ...
dpkg: warning: files list file for package 'python3-commandnotfound' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'apturl-common' missing; assuming package has no files currently installed
(Reading database ... 220697 files and directories currently installed.)
Preparing to unpack .../ubuntu-advantage-tools_27.9~20.04.1_amd64.deb ...

/var/lib/dpkg/info/ubuntu-advantage-tools.prerm: 48: py3clean: not found...................................................................................................................................................] 
dpkg: warning: old ubuntu-advantage-tools package pre-removal script subprocess returned error exit status 127
dpkg: trying script from the new package instead ...
Failed to stop ubuntu-advantage.service: Unit ubuntu-advantage.service not loaded.
/var/lib/dpkg/tmp.ci/prerm: 48: py3clean: not found
dpkg: error processing archive /var/cache/apt/archives/ubuntu-advantage-tools_27.9~20.04.1_amd64.deb (--unpack):
 new ubuntu-advantage-tools package pre-removal script subprocess returned error exit status 127
/var/lib/dpkg/info/ubuntu-advantage-tools.postinst: 451: py3compile: not found
dpkg: error while cleaning up:
 installed ubuntu-advantage-tools package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 /var/cache/apt/archives/ubuntu-advantage-tools_27.9~20.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
prajesh@revyz-113:~$ sudo apt autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  ubuntu-advantage-tools
The following packages will be REMOVED:
  linux-headers-5.13.0-48-generic linux-hwe-5.13-headers-5.13.0-48 linux-image-5.13.0-48-generic linux-modules-5.13.0-48-generic linux-modules-extra-5.13.0-48-generic
The following packages will be upgraded:
  ubuntu-advantage-tools
1 upgraded, 0 newly installed, 5 to remove and 0 not upgraded.
4 not fully installed or removed.
Need to get 0 B/876 kB of archives.
After this operation, 508 MB disk space will be freed.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
dpkg: warning: files list file for package 'python3-commandnotfound' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'apturl-common' missing; assuming package has no files currently installed
(Reading database ... 220697 files and directories currently installed.)
Preparing to unpack .../ubuntu-advantage-tools_27.9~20.04.1_amd64.deb ...

/var/lib/dpkg/info/ubuntu-advantage-tools.prerm: 48: py3clean: not found...................................................................................................................................................] 
dpkg: warning: old ubuntu-advantage-tools package pre-removal script subprocess returned error exit status 127
dpkg: trying script from the new package instead ...
Failed to stop ubuntu-advantage.service: Unit ubuntu-advantage.service not loaded.
/var/lib/dpkg/tmp.ci/prerm: 48: py3clean: not found
dpkg: error processing archive /var/cache/apt/archives/ubuntu-advantage-tools_27.9~20.04.1_amd64.deb (--unpack):
 new ubuntu-advantage-tools package pre-removal script subprocess returned error exit status 127
/var/lib/dpkg/info/ubuntu-advantage-tools.postinst: 451: py3compile: not found
dpkg: error while cleaning up:
 installed ubuntu-advantage-tools package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 /var/cache/apt/archives/ubuntu-advantage-tools_27.9~20.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

有一些非常严重的问题使用您当前的安装:

  • 命令输出中的错误apt-get upgrade是由于系统上的 python 安装损坏造成的...您对默认的 python3 安装执行了一些操作,导致其无法运行。

  • python3.8中存在符号链接,/usr/bin但二进制文件本身/usr/bin/python3.8缺失(可能删除了二进制文件,甚至python3.8完全删除)。

  • 命令输出中的错误apt install python-is-python3表明您已经更改/etc/apt/sources.list并添加了来自不同版本/版本的混合源,这是完全不推荐的并且应该避免。

虽然你可以按照以下步骤轻松修复你的来源列表这个答案Python3您的系统上的安装似乎已严重损坏……尽管高级用户可能能够修复它(即使如此,这个过程仍然很漫长,而且容易出错), 普通用户无法...python3对于 Ubuntu 20.04 来说至关重要,没有它几乎没有任何东西可以正常运行...请参阅这个答案了解详细信息。

全新安装是您最容易做出的正确决定...我建议您 备份你的数据然后全新安装 Ubuntu,不要再使用 python。

答案2

不确定我是否处于同样的困境,但以下命令(在这个答案)只是修复了我的py3compile: not found错误:

sudo apt install -f --reinstall python3-minimal

相关内容