Can no longer use apt-get to install due to error with apport [closed]

I am working on a Windows 7 PC with a Xubuntu (Ubuntu 14.04.2 LTS, 64-bit) Virtual Box. Lately I have been having problems using the 'apt-get' command, and also the Software Updater. The Software Updater cannot download one of the updates-- I have apport 2.14.1-0ubuntu3.10 and it is trying to install 2.14.1-0ubuntu3.11, but fails.

Also, when I type any kind of 'apt-get' or 'dpkg' command, like 'apt-get upgrade', I get errors like the following, does anyone know what I can do?

Reading package lists...
Building 
dependency tree...
Reading state information...
The following packages will be upgraded:
  apport
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
Need to get 0 B/180 kB of archives.
After this operation, 20.5 kB of additional disk space will be used.
Do you want to continue? [Y/n] (Reading database ... 314480 files and directories currently installed.)
Preparing to unpack .../apport_2.14.1-0ubuntu3.11_all.deb ...
initctl: Unknown job: apport
  File "/usr/bin/pyclean", line 63
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
initctl: Unknown job: apport
  File "/usr/bin/pyclean", line 63
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: error processing archive /var/cache/apt/archives/apport_2.14.1-0ubuntu3.11_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 35, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/apport_2.14.1-0ubuntu3.11_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Solution 1:

I just tried to compile the python file /usr/bin/pyclean on my pc, i compile it with python3 and I got the same error, while when I compile it with python2 there is no error.

So, I guess that you changed something in your system that makes the default python version python3.

You can try to fix this like so:

  • Execute the command ls -l /usr/bin/python and see its output.
  • If the file /usr/bin/python point to python3.x , then remove the link and replace it with a link to python2

    sudo rm /usr/bin/python
    sudo ln -s /usr/bin/python2.7 /usr/bin/python
    

    Now python2.7 will be back as the default python version in your system as it should be