处理时出错:python3-apt、usb-creator、apport、python-apt

处理时出错:python3-apt、usb-creator、apport、python-apt

我不是 Ubuntu 的高级用户,但我遇到了一个大问题。当我运行:

sudo apt-get update && sudo apt-get upgrade

我得到以下输出:

Hit:1 http://pl.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://pl.archive.ubuntu.com/ubuntu bionic-updates InRelease                  
Hit:3 http://pl.archive.ubuntu.com/ubuntu bionic-backports InRelease                
Hit:4 http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu bionic InRelease         
Ign:5 http://download.opensuse.org/repositories/home:/manuelschneid3r/xUbuntu_18.04  InRelease
Hit:6 http://download.opensuse.org/repositories/home:/manuelschneid3r/xUbuntu_18.04  Release
Hit:7 http://ppa.launchpad.net/team-xbmc/ppa/ubuntu bionic InRelease                
Hit:8 https://dl.winehq.org/wine-builds/ubuntu bionic InRelease                     
Hit:9 http://security.ubuntu.com/ubuntu bionic-security InRelease                   
Hit:11 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease      
Reading package lists... Done                                  
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  linux-generic-hwe-18.04 linux-headers-generic-hwe-18.04
  linux-image-generic-hwe-18.04
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
6 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-apt (1.6.4) ...
/bin/sh: 1: /usr/bin/python3.6: Permission denied
Traceback (most recent call last):
  File "/usr/bin/py3compile", line 290, in <module>
    main()
  File "/usr/bin/py3compile", line 270, in main
    options.force, options.optimize, e_patterns)
  File "/usr/bin/py3compile", line 156, in compile
    cfn = interpreter.cache_file(fn, version)
  File "/usr/share/python3/debpython/interpreter.py", line 212, in cache_file
    (fname[:-3], self.magic_tag(version), last_char))
  File "/usr/share/python3/debpython/interpreter.py", line 246, in magic_tag
    return self._execute('import imp; print(imp.get_tag())', version)
  File "/usr/share/python3/debpython/interpreter.py", line 359, in _execute
    raise Exception('{} failed with status code {}'.format(command, output['returncode']))
Exception: python3.6 -c 'import imp; print(imp.get_tag())' failed with status code 126
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "/usr/bin/py3compile", line 290, in <module>
    main()
  File "/usr/bin/py3compile", line 270, in main
    options.force, options.optimize, e_patterns)
  File "/usr/bin/py3compile", line 156, in compile
    cfn = interpreter.cache_file(fn, version)
  File "/usr/share/python3/debpython/interpreter.py", line 212, in cache_file
    (fname[:-3], self.magic_tag(version), last_char))
  File "/usr/share/python3/debpython/interpreter.py", line 246, in magic_tag
    return self._execute('import imp; print(imp.get_tag())', version)
  File "/usr/share/python3/debpython/interpreter.py", line 359, in _execute
    raise Exception('{} failed with status code {}'.format(command, output['returncode']))
Exception: python3.6 -c 'import imp; print(imp.get_tag())' failed with status code 126
dpkg: error processing package python3-apt (--configure):
 installed python3-apt package post-installation script subprocess returned error exit status 1
Setting up usb-creator-common (0.3.5ubuntu18.04.2) ...
/bin/sh: 1: /usr/bin/python3.6: Permission denied
Traceback (most recent call last):
  File "/usr/bin/py3compile", line 290, in <module>
    main()
  File "/usr/bin/py3compile", line 270, in main
    options.force, options.optimize, e_patterns)
  File "/usr/bin/py3compile", line 156, in compile
    cfn = interpreter.cache_file(fn, version)
  File "/usr/share/python3/debpython/interpreter.py", line 212, in cache_file
    (fname[:-3], self.magic_tag(version), last_char))
  File "/usr/share/python3/debpython/interpreter.py", line 246, in magic_tag
    return self._execute('import imp; print(imp.get_tag())', version)
  File "/usr/share/python3/debpython/interpreter.py", line 359, in _execute
    raise Exception('{} failed with status code {}'.format(command, output['returncode']))
Exception: python3.6 -c 'import imp; print(imp.get_tag())' failed with status code 126
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "/usr/bin/py3compile", line 290, in <module>
    main()
  File "/usr/bin/py3compile", line 270, in main
    options.force, options.optimize, e_patterns)
  File "/usr/bin/py3compile", line 156, in compile
    cfn = interpreter.cache_file(fn, version)
  File "/usr/share/python3/debpython/interpreter.py", line 212, in cache_file
    (fname[:-3], self.magic_tag(version), last_char))
  File "/usr/share/python3/debpython/interpreter.py", line 246, in magic_tag
    return self._execute('import imp; print(imp.get_tag())', version)
  File "/usr/share/python3/debpython/interpreter.py", line 359, in _execute
    raise Exception('{} failed with status code {}'.format(command, output['returncode']))
Exception: python3.6 -c 'import imp; print(imp.get_tag())' failed with status code 126
dpkg: error processing package usb-creator-common (--configure):
 installed usb-creator-common package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of usb-creator-gtk:
 usb-creator-gtk depends on usb-creator-common (= 0.3.5ubuntu18.04.2); however:
  Package usb-creator-common is not configured yet.

dpkg: error processing package usb-creator-gtk (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                     dpkg: dependency problems prevent configuration of python3-apport:
 python3-apport depends on python3-apt (>= 0.7.9); however:
  Package python3-apt is not configured yet.

dpkg: error processing package python3-apport (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of apport:
 apport depends on python3-apport (>= 2.20.9-0ubuntu7.7); however:
  Package python3-apport is not configured yet.

dpkg: error processing package apport (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              No apport report written because MaxReports is reached already
                                       Setting up python-apt (1.6.4) ...
/var/lib/dpkg/info/python-apt.postinst: 6: /var/lib/dpkg/info/python-apt.postinst: pycompile: Permission denied
dpkg: error processing package python-apt (--configure):
 installed python-apt package post-installation script subprocess returned error exit status 126
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 python3-apt
 usb-creator-common
 usb-creator-gtk
 python3-apport
 apport
 python-apt
E: Sub-process /usr/bin/dpkg returned an error code (1)

我尝试了此站点上的许多不同解决方案,但对我都不起作用。当我尝试将 Python 从 3.6 更新到 3.7 时,出现了问题。如果我谈论的话题已经存在,我很抱歉,但我找不到任何可以解决所有这些错误的解决方案。我可以添加您想要的任何命令输出,但正如我所说,我不是非常高级的用户。


@没有人

输入:

sudo dpkg -i python3-apt_1.6.0_amd64.deb python-apt_1.6.0_amd64.deb

输出:

dpkg: warning: downgrading python3-apt from 1.6.4 to 1.6.0
(Reading database ... 182414 files and directories currently installed.)
Preparing to unpack python3-apt_1.6.0_amd64.deb ...
Unpacking python3-apt (1.6.0) over (1.6.4) ...
Preparing to unpack python-apt_1.6.0_amd64.deb ...
/var/lib/dpkg/info/python-apt.prerm: 6: /var/lib/dpkg/info/python-apt.prerm: pyclean: Permission denied
dpkg: error processing archive python-apt_1.6.0_amd64.deb (--install):
 installed python-apt package pre-removal script subprocess returned error exit status 126
/var/lib/dpkg/info/python-apt.postinst: 6: /var/lib/dpkg/info/python-apt.postinst: pycompile: Permission denied
dpkg: error while cleaning up:
 installed python-apt package post-installation script subprocess returned error exit status 126
Setting up python3-apt (1.6.0) ...
/bin/sh: 1: /usr/bin/python3.6: Permission denied
Traceback (most recent call last):
  File "/usr/bin/py3compile", line 290, in <module>
    main()
  File "/usr/bin/py3compile", line 270, in main
    options.force, options.optimize, e_patterns)
  File "/usr/bin/py3compile", line 156, in compile
    cfn = interpreter.cache_file(fn, version)
  File "/usr/share/python3/debpython/interpreter.py", line 212, in cache_file
    (fname[:-3], self.magic_tag(version), last_char))
  File "/usr/share/python3/debpython/interpreter.py", line 246, in magic_tag
    return self._execute('import imp; print(imp.get_tag())', version)
  File "/usr/share/python3/debpython/interpreter.py", line 359, in _execute
    raise Exception('{} failed with status code {}'.format(command, output['returncode']))
Exception: python3.6 -c 'import imp; print(imp.get_tag())' failed with status code 126
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "/usr/bin/py3compile", line 290, in <module>
    main()
  File "/usr/bin/py3compile", line 270, in main
    options.force, options.optimize, e_patterns)
  File "/usr/bin/py3compile", line 156, in compile
    cfn = interpreter.cache_file(fn, version)
  File "/usr/share/python3/debpython/interpreter.py", line 212, in cache_file
    (fname[:-3], self.magic_tag(version), last_char))
  File "/usr/share/python3/debpython/interpreter.py", line 246, in magic_tag
    return self._execute('import imp; print(imp.get_tag())', version)
  File "/usr/share/python3/debpython/interpreter.py", line 359, in _execute
    raise Exception('{} failed with status code {}'.format(command, output['returncode']))
Exception: python3.6 -c 'import imp; print(imp.get_tag())' failed with status code 126
dpkg: error processing package python3-apt (--install):
 installed python3-apt package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 python-apt_1.6.0_amd64.deb
 python3-apt

我希望重新安装系统不是解决问题的唯一方法

答案1

内部错误听起来不太好。

wget -c http://mirrors.kernel.org/ubuntu/pool/main/p/python-apt/python3-apt_1.6.0_amd64.deb

wget -c http://mirrors.kernel.org/ubuntu/pool/main/p/python-apt/python-apt_1.6.0_amd64.deb

使用以下命令安装 2 个包sudo dpkg -i python3-apt_1.6.0_amd64.deb python-apt_1.6.0_amd64.deb

如果这个工作sudo dpkg --configure -a && sudo apt -f install

然后升级你的系统

sudo apt full-upgrade

答案2

我在使用 Python 3.10.4 的 Ubuntu 22.04 上遇到了同样的问题。以下命令解决了该问题:

sudo apt --fix-broken install

相关内容