'System malfunctioning after uninstalling python3

I use Parrot OS v4.7, there was an issue with Pyinstaller (Dependencies problem but all the dependencies were fulfilled/installed) so I googled and tried to uninstall and reinstall Python3.

I ran

apt-get remove python3

but it started removing other packages as well, now the computer is not functioning normally.

It deleted:

  • Mate-interface
  • bluefish

screenshot is not working, it says:

Failed to execute child process “mate-screenshot” (No   such file or directory))
  • dashboard

  • and many other packages, the system is not functioning as it was before.

and now when I try to reinstall Python3 to get them back, error occurs. It gives the following output while running

When i run

apt-get install python3

or

apt-get install --reinstall python3

i get:

(Reading database ... 401001 files and directories currently installed.)
Preparing to unpack .../python3_3.7.5-3_amd64.deb ...
running python pre-rtupdate hooks for python3.7...
Unpacking python3 (3.7.5-3) over (3.7.5-3) ...
Setting up python3 (3.7.5-3) ...
running python rtupdate hooks for python3.7...
running python post-rtupdate hooks for python3.7...
Setting up python3-lib2to3 (3.8.0-1) ...
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.8'
  isolated = 0
  environment = 0
  user site = 1
  import site = 0
  sys._base_executable = '/usr/bin/python3.8'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.executable = '/usr/bin/python3.8'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python38.zip',
    '/usr/lib/python3.8',
    '/usr/lib/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the file
system encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f763db09740 (most recent call first):
<no Python frame>
dpkg: error processing package python3-lib2to3 (--configure):
 installed python3-lib2to3 package post-installation script subprocess returned 
error exit status 1
dpkg: dependency problems prevent configuration of python3-distutils:
 python3-distutils depends on python3-lib2to3 (>= 3.6.4); however:
  Package python3-lib2to3 is not configured yet.

dpkg: error processing package python3-distutils (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-all:
 python3-all depends on python3-distutils (>= 3.7.5-1~); however:
  Package python3-distutils is not configured yet.

dpkg: error processing package python3-all (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-dev:
 python3-dev depends on python3-distutils (>= 3.7.5-1~); however:
  Package python3-distutils is not configured yet.

dpkg: error processing package python3-dev (--configure):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.9.0-2) ...
Errors were encountered while processing:
 python3-lib2to3
 python3-distutils
 python3-all
 python3-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)

Please help me to reinstall the Python3 and get the deleted packages back such that the computer may work properly.

Mostly it deleted the system packages.



Solution 1:[1]

been there done that. You won't get it working unless you are capable of building linux from scratch :)

reinstall is fastest way forward.

Solution 2:[2]

Ok so first to install pentesting tools that are uninstalled use this command

sudo apt-get install parrot-tools-full

and also when you uninstall python3 some editing tools are also uninstalled like libreoffice .. the reinstall mate linux evironment

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 esr
Solution 2 Gerson Dantas