SyntaxError while setting up python3-aptdaemon

[ aug ,11 : 21.20 ] hi all. while troubleshooting i created new problem. kindly refer below link

How to reinstall APT package

Result of reinstallation :

$ 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

another result about pkg: for update.

$ 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 

updated output of solution :

$ 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$ 

Whenever I try to install any software it gives me following error. I have tried sudo apt-get install -f but it outputs

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)

>


Solution 1:

This is because of the incompatibility of Python 3 version. You have installed Python version 3.7.3 and made it default. The default version of Python 3 in 18.04 Bionic Beaver is 3.6.8. You need to switch back to version 3.6.8. To do so, run

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
sudo update-alternatives --config python3

and enter 1.

Related bug reports:

  • Bug #1830272 - Launchpad
  • #909095 - fails to install - Debian Bug report logs

Solution 2:

I ran across this issue today. Seems like async has been added as a functional symbol between 3.6.8 and 3.6.9 (which is ridiculous - such thing should not change between patch levels).
I had to edit /usr/lib/python3/dist-packages/aptdaemon/client.py and replace each occurrence of "async" with a different variable name (I just appended a character). After this my system was able to install all the missing packages again.

So the real culprit seems to be a change in Python3 that seems out of scope of the version change.

Solution 3:

These following command worked for me :

sudo apt-get remove python3-apt
sudo apt-get install python3-apt
sudo apt remove python3-aptdaemon
sudo apt install python3-aptdaemon