Ik gebruik Ubuntu 20.04.1 op een desktop. Het is mogelijk dat ik maanden geleden het python2-binaire bestand heb overschreven met het python3-bestand om iets te laten werken. (Waarom Is python2 toch op normale systemen geïnstalleerd?)
In elk geval heb ik geprobeerd apt upgrade
uit te voeren en het mislukte, waarbij ik het python-apt
-pakket de schuld gaf.
$ 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)
] Ik heb geprobeerd het pakket te verwijderen, maar dat is ook mislukt:
$ 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)
Hier is hoe de binaire bestanden eruit zien:
$ 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*
En hier is mijn versie-informatie:
$ python --version
Python 3.8.5
$ python2 --version
Python 3.8.5
De Python2-versie, gezien de symlinks in / usr / bin
, is een beetje vreemd.
Heeft iemand ideeën?
Update: ik zag net een ander deel van die foutmelding:
"ModuleNotFoundError: No module named 'ConfigParser'"
Ik zag iemand online schrijven dat Python 3 het 'configparser' (kleine letters) noemt. Zou dat het probleem kunnen zijn? Als dat zo is, waarom ervaart dan niet iedereen het ook?
По какой-то причине оказалось, что мне нужно пересоздать бинарный файл Python2. Я нашел решение на этой странице Вот как это работало:
apt-get download python2.7-minimal
ar x python2.7-minimal_2.7.18-1~20.04_amd64.deb data.tar.xz
sudo tar xJf data.tar.xz -C / './usr/bin/python2.7'
rm data.tar.xz