3

The title says it all in short. I tried to purge all of my python installations as they were a mess. Turned out I broke everything and was not able to install or uninstall anything with apt-get or dpkg, only got the following error message (or similar) various times:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libexpat1-dev libpython3.7 libpython3.7-dev libpython3.7-minimal libpython3.7-stdlib libpython3.8
  libpython3.8-dev libpython3.8-minimal libpython3.8-stdlib zlib1g-dev
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  python3
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 191 kB disk space will be freed.
Do you want to continue? [Y/n] Y
dpkg: error processing package python3 (--remove):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting a removal
Errors were encountered while processing:
 python3
E: Sub-process /usr/bin/dpkg returned an error code (1)

What sudo dpkg --audit currently gives me is:

sudo dpkg --audit
The following packages are only half configured, probably due to problems
configuring them the first time.  The configuration should be retried using
dpkg --configure <package> or the configure menu option in dselect:
 python3-lib2to3      Interactive high-level object-oriented language (2to3, ve
 python3-minimal      minimal subset of the Python language (default python3 ve

The following packages are missing the list control file in the
database, they need to be reinstalled:
 libpython3-stdlib:amd64 interactive high-level object-oriented language (default
 libpython3.6:amd64   Shared Python runtime library (version 3.6)
 libpython3.6-minimal:amd64 Minimal subset of the Python language (version 3.6)
 libpython3.6-stdlib:amd64 Interactive high-level object-oriented language (standard
 libpython3.7:amd64   Shared Python runtime library (version 3.7)
 libpython3.7-dev:amd64 Header files and a static library for Python (v3.7)
 libpython3.7-minimal:amd64 Minimal subset of the Python language (version 3.7)
 libpython3.7-stdlib:amd64 Interactive high-level object-oriented language (standard
 libpython3.8:amd64   Shared Python runtime library (version 3.8)
 libpython3.8-dev:amd64 Header files and a static library for Python (v3.8)
 libpython3.8-minimal:amd64 Minimal subset of the Python language (version 3.8)
 libpython3.8-stdlib:amd64 Interactive high-level object-oriented language (standard
 python3.6            Interactive high-level object-oriented language (version
 python3.6-minimal    Minimal subset of the Python language (version 3.6)

The following packages are missing the md5sums control file in the
database, they need to be reinstalled:
 libpython3-stdlib:amd64 interactive high-level object-oriented language (default
 libpython3.6:amd64   Shared Python runtime library (version 3.6)
 libpython3.6-minimal:amd64 Minimal subset of the Python language (version 3.6)
 libpython3.6-stdlib:amd64 Interactive high-level object-oriented language (standard
 libpython3.7:amd64   Shared Python runtime library (version 3.7)
 libpython3.7-dev:amd64 Header files and a static library for Python (v3.7)
 libpython3.7-minimal:amd64 Minimal subset of the Python language (version 3.7)
 libpython3.7-stdlib:amd64 Interactive high-level object-oriented language (standard
 libpython3.8:amd64   Shared Python runtime library (version 3.8)
 libpython3.8-dev:amd64 Header files and a static library for Python (v3.8)
 libpython3.8-minimal:amd64 Minimal subset of the Python language (version 3.8)
 libpython3.8-stdlib:amd64 Interactive high-level object-oriented language (standard
 python3.6            Interactive high-level object-oriented language (version
 python3.6-minimal    Minimal subset of the Python language (version 3.6)

Using sudo dpkg --configure on both python3-minimal and python3-lib2to3 gives me the following:

Setting up python3-minimal (3.6.7-1~18.04) ...
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007fa5074f0740 (most recent call first):
Aborted (core dumped)
dpkg: error processing package python3-minimal (--configure):
 installed python3-minimal package post-installation script subprocess returned error exit status 134
Errors were encountered while processing:
 python3-minimal
$ sudo dpkg --configure python3-lib2to3
Setting up python3-lib2to3 (3.6.9-1~18.04) ...
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f439a7a0740 (most recent call first):
Aborted (core dumped)
dpkg: error processing package python3-lib2to3 (--configure):
 installed python3-lib2to3 package post-installation script subprocess returned error exit status 134
Errors were encountered while processing:
 python3-lib2to3```

I have tried everything found [here][1], and have no idea what to try next. Anyone run into such a mess of a package removal before?


  [1]: https://phoenixnap.com/kb/fix-sub-process-usr-bin-dpkg-returned-error-code-1
  • 2
    Looks like things were pretty broken before you got to the attempted uninstall. – jordanm Feb 20 '20 at 19:21
  • 2
    How difficult would it be to remove them manually or semi-manually? – AMC Feb 20 '20 at 19:24
  • 1
    I have tried to find all python-related files and remove them (move to tmp), but nothing has cleared the problem. I still have a very messed up half-installed python3 somewhere that prohibits me from using apt-get or dpkg. – Ippa Seppälä Feb 20 '20 at 19:53

1 Answers1

1

Have you tried --remove --force ?

hedgethe
  • 55
  • 1
  • 8
  • 1
    Yes, using `sudo apt-get -f remove python3-minimal`I get the following message: `Reading package lists... Done Building dependency tree Reading state information... Done Package 'python3-minimal' is not installed, so not removed You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies: python3 : PreDepends: python3-minimal (= 3.6.7-1~18.04) but it is not going to be installed E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).` – Ippa Seppälä Feb 20 '20 at 19:49
  • 1
    And running `sudo apt --fix-broken install` gives me : `Errors were encountered while processing: python3-minimal E: Sub-process /usr/bin/dpkg returned an error code (1)` – Ippa Seppälä Feb 20 '20 at 19:51