![设置 python3-aptdaemon 时出现语法错误](https://linux22.com/image/1167259/%E8%AE%BE%E7%BD%AE%20python3-aptdaemon%20%E6%97%B6%E5%87%BA%E7%8E%B0%E8%AF%AD%E6%B3%95%E9%94%99%E8%AF%AF.png)
[ 8 月 11 日:21.20 ] 大家好。在排除故障时,我遇到了新问题。请参考以下链接
重新安装的结果:
$ sudo apt install --reinstall python3-aptdaemon
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 7 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for python3-aptdaemon:amd64
ariel@ariel:~$ sudo apt install --reinstall python3-aptdaemon
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 7 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for python3-aptdaemon:amd64
关于 pkg 的另一个结果:用于更新。
$ sudo apt-get update
Hit:1 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:4 http://ppa.launchpad.net/diesch/testing/ubuntu bionic InRelease
Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Ign:6 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic InRelease
Err:7 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic Release
404 Not Found [IP: 91.189.95.83 80]
Traceback (most recent call last):
File "/usr/lib/cnf-update-db", line 8, in <module>
from CommandNotFound.db.creator import DbCreator
File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 11, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
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/lib/cnf-update-db", line 8, in <module>
from CommandNotFound.db.creator import DbCreator
File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 11, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
E: Sub-process returned an error code
解决方案的更新输出:
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
update-alternatives: using /usr/bin/python3.6 to provide /usr/bin/python3 (python3) in auto mode
ariel@ariel:/etc/apt/sources.list.d
$ sudo update-alternatives --config python3
There is only one alternative in link group python3 (providing /usr/bin/python3): /usr/bin/python3.6
Nothing to configure.
ariel@ariel:/etc/apt/sources.list.d$ 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.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up python3-aptdaemon (1.1.1+bzr982-0ubuntu19.1) ...
File "/usr/lib/python3/dist-packages/aptdaemon/client.py", line 1570
async = reply_handler and error_handler
^
SyntaxError: invalid syntax
dpkg: error processing package python3-aptdaemon (--configure):
installed python3-aptdaemon package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of python3-aptdaemon.gtk3widgets:
python3-aptdaemon.gtk3widgets depends on python3-aptdaemon (= 1.1.1+bzr982-0ubuntu19.1); however:
Package python3-aptdaemon is not configured yet.
dpkg: error processing package python3-aptdaemon.gtk3widgets (--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 language-selector-gnome:
language-selector-gnome depends on python3-aptdaemon.gtk3widgets; however:
Package python3-aptdaemon.gtk3widgets is not configured yet.
No apport report written because the error message indicates its a followup error from a previous failure.
dpkg: error processing package language-selector-gnome (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of ubuntu-desktop:
ubuntu-desktop depends on language-selector-gnome; however:
Package language-selector-gnome is not configured yet.
dpkg: error processing package ubuntu-desktop (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
Errors were encountered while processing:
python3-aptdaemon
python3-aptdaemon.gtk3widgets
language-selector-gnome
ubuntu-desktop
E: Sub-process /usr/bin/dpkg returned an error code (1)
ariel@ariel:/etc/apt/sources.list.d$
每当我尝试安装任何软件时,它都会出现以下错误。我试过了,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.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up python3-aptdaemon (1.1.1+bzr982-0ubuntu19.1) ...
File "/usr/lib/python3/dist-packages/aptdaemon/client.py", line 1570
async = reply_handler and error_handler
^
SyntaxError: invalid syntax
dpkg: error processing package python3-aptdaemon (--configure):
installed python3-aptdaemon package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of python3-aptdaemon.gtk3widgets:
python3-aptdaemon.gtk3widgets depends on python3-aptdaemon (= 1.1.1+bzr982-0ubuntu19.1); however:
Package python3-aptdaemon is not configured yet.
dpkg: error processing package python3-aptdaemon.gtk3widgets (--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 language-selector-gnome:
language-selector-gnome depends on python3-aptdaemon.gtk3widgets; however:
Package python3-aptdaemon.gtk3widgets is not configured yet.
dpkg: error processing package language-selector-gnome (--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 ubuntu-desktop:
ubuntu-desktop depends on language-selector-gnome; however:
Package language-selector-gnome is not configured yet.
dpkg: error processing package ubuntu-desktop (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
Errors were encountered while processing:
python3-aptdaemon
python3-aptdaemon.gtk3widgets
language-selector-gnome
ubuntu-desktop
E: Sub-process /usr/bin/dpkg returned an error code (1)
$ sudo apt clean && sudo apt autoclean && sudo apt remove && sudo apt autoremove -y && sudo apt install -f && sudo dpkg --configure -a && sudo apt update && sudo apt full-upgrade
[sudo] password for ariel:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up python3-aptdaemon (1.1.1+bzr982-0ubuntu19.1) ...
File "/usr/lib/python3/dist-packages/aptdaemon/client.py", line 1570
async = reply_handler and error_handler
^
SyntaxError: invalid syntax
dpkg: error processing package python3-aptdaemon (--configure):
installed python3-aptdaemon package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of python3-aptdaemon.gtk3widgets:
python3-aptdaemon.gtk3widgets depends on python3-aptdaemon (= 1.1.1+bzr982-0ubuntu19.1); however:
Package python3-aptdaemon is not configured yet.
dpkg: error processing package python3-aptdaemon.gtk3widgets (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of language-selector-gnome:
language-selector-gnome depends on python3-aptdaemon.gtk3widgets; however:
Package python3-aptdaemon.gtk3widgets is not configured yet.
dpkg: error processing package language-selector-gnome (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of ubuntu-desktop:
ubuntu-desktop depends on language-selector-gnome; however:
Package language-selector-gnome is not configured yet.
dpkg: error processing package ubuntu-desktop (--configure):
dependency problems - leavinNo 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.
No apport report written because MaxReports is reached already
g unconfigured
Errors were encountered while processing:
python3-aptdaemon
python3-aptdaemon.gtk3widgets
language-selector-gnome
ubuntu-desktop
E: Sub-process /usr/bin/dpkg returned an error code (1)
>
答案1
这是因为 Python 3 版本不兼容。您安装了 Python 版本 3.7.3 并将其设为默认版本。18.04 Bionic Beaver 中的 Python 3 默认版本是 3.6.8。您需要切换回版本 3.6.8。为此,请运行
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
sudo update-alternatives --config python3
并输入 1。
相关错误报告:
答案2
我今天遇到了这个问题。似乎 async 已作为功能符号添加到 3.6.8 和 3.6.9 之间(这太荒谬了 - 这种东西不应该在补丁级别之间发生变化)。
我不得不编辑/usr/lib/python3/dist-packages/aptdaemon/client.py
并将每个出现的“async”替换为不同的变量名(我只是附加了一个字符)。此后,我的系统能够再次安装所有缺失的软件包。
因此真正的罪魁祸首似乎是 Python3 中的变化,而这种变化似乎超出了版本变化的范围。
答案3
以下命令对我有用:
sudo apt-get remove python3-apt
sudo apt-get install python3-apt
sudo apt remove python3-aptdaemon
sudo apt install python3-aptdaemon