0

Basically the title. My Python installations were all mixed up, so I ran

sudo apt purge --autoremove python3 python3-venv python3-pip
sudo rm -rf /usr/lib/python3* /usr/bin/python3*

Now dpkg is broken, so I can't install anything:

$ sudo apt install python3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
YThe following additional packages will be installed:
  libpython3-stdlib python3-minimal python3.10
Suggested packages:
  python3-doc python3-tk python3-venv python3.10-venv python3.10-doc
The following NEW packages will be installed:
  libpython3-stdlib python3 python3-minimal python3.10
0 upgraded, 4 newly installed, 0 to remove and 22 not upgraded.
1 not fully installed or removed.
Need to get 0 B/562 kB of archives.
After this operation, 906 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline
Setting up python3.10-minimal (3.10.12-1~22.04.9) ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = '/usr/bin/python3.10'
  isolated = 0
  environment = 0
  user site = 1
  import site = 0
  sys._base_executable = '/usr/bin/python3.10'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.platlibdir = 'lib'
  sys.executable = '/usr/bin/python3.10'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python310.zip',
    '/usr/lib/python3.10',
    '/usr/lib/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007fb149ed5000 (most recent call first): <no Python frame> dpkg: error processing package python3.10-minimal (--configure): installed python3.10-minimal package post-installation script subprocess returned error exit status 1 Errors were encountered while processing: python3.10-minimal E: Sub-process /usr/bin/dpkg returned an error code (1)

So I removed python3-minimal, which, I gather, is very, very bad. How do I repair this situation?

0 Answers0