I'm using Ubuntu 20.04.1 on a desktop. It's possible that, months ago, I overwrote the python2 binary with the python3 file to make something work. (Why do any normal systems still have python2 installed anyway?)
In any case, I just tried to run apt upgrade
and it failed, blaming the python-apt
package.
$ sudo apt upgrade
Preparing to unpack .../python-apt_2.0.0ubuntu0.20.04.2_amd64.deb ...
File "/usr/bin/pyclean", line 63
except (IOError, OSError), e:
^
SyntaxError: invalid syntax
dpkg: warning: old python-apt package pre-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
File "/usr/bin/pyclean", line 63
except (IOError, OSError), e:
SyntaxError: invalid syntax
dpkg: error processing archive /var/cache/apt/archives/python-apt_2.0.0ubuntu0.2
0.04.2_amd64.deb (--unpack):
new python-apt package pre-removal script subprocess 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
ModuleNotFoundError: No module named 'ConfigParser'
dpkg: error while cleaning up:
installed python-apt package post-installation script subprocess returned error
exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/python-apt_2.0.0ubuntu0.20.04.2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
I tried purging the package but that failed, too:
$ apt purge python-apt
[...]
Do you want to continue? [Y/n]
dpkg: error processing package python-apt (--remove):
package is in a very bad inconsistent state; you should
reinstall it before attempting a removal
dpkg: too many errors, stopping
Errors were encountered while processing:
python-apt
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
Here's what the binaries look like:
$ ll /usr/bin | grep python
-rwxr-xr-x 1 root root 1057 Mar 13 2020 dh_python2*
lrwxrwxrwx 1 root root 23 Aug 4 07:16 pdb2.7 -> ../lib/python2.7/pdb.py*
lrwxrwxrwx 1 root root 23 Jul 28 08:59 pdb3.8 -> ../lib/python3.8/pdb.py*
lrwxrwxrwx 1 root root 31 Mar 13 2020 py3versions -> ../share/python3/py3versions.py*
lrwxrwxrwx 1 root root 7 Apr 15 2020 python -> python2*
lrwxrwxrwx 1 root root 9 Mar 13 2020 python2 -> python2.7*
-rwxr-xr-x 1 root root 5486352 Oct 25 14:14 python2.7*
lrwxrwxrwx 1 root root 9 Mar 13 2020 python3 -> python3.8*
-rwxr-xr-x 1 root root 5486352 Jul 28 08:59 python3.8*
-rwxr-xr-x 1 root root 384 Mar 27 2020 python3-futurize*
-rwxr-xr-x 1 root root 388 Mar 27 2020 python3-pasteurize*
lrwxrwxrwx 1 root root 29 Mar 13 2020 pyversions -> ../share/python/pyversions.py*
And here's my version information:
$ python --version
Python 3.8.5
$ python2 --version
Python 3.8.5
The Python2 one, considering the symlinks in /usr/bin
, is a bit strange.
Does anyone have any ideas?
Update: I just noticed a different part of that error message:
"ModuleNotFoundError: No module named 'ConfigParser'"
I saw someone writing online that Python 3 calls it 'configparser' (lowercase). Could that be the problem? If it is, why isn't everyone else experiencing it, too?