0

My python 2 and 3 interpreters in /usr/bin somehow got deleted and now I am unable to reinstall either. I see that similar questions have been asked earlier(I accidentally deleted /usr/bin/python. How do I restore it?) but trying to reinstall using sudo apt-get install --reinstall python2.7 fails with the following message, and a list of about 15 packages:

E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

When I run sudo apt --fix-broken install it fails with the following error message:

Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
/usr/bin/python2.7: can't open file '/usr/lib/python2.7/py_compile.py': [Errno 2] No such file or directory
dpkg: error processing package python2.7-minimal (--configure):
 installed python2.7-minimal package post-installation script subprocess returned error exit status 2
dpkg: dependency problems prevent configuration of python-minimal:
 python-minimal depends on python2.7-minimal (>= 2.7.15~rc1-1~); however:
  Package python2.7-minimal is not configured yet.

dpkg: error processing package python-minimal (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Errors were encountered while processing:
 python2.7-minimal
 python-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)

This happens despite setting PYTHONHOME to /usr/local/lib or /usr/lib, prior to running the above command.

Trying to reinstall python2.7-minimal first also produces the same errors.

I have no trouble accessing the terminal, and attempting to reinstall python3 using sudo apt-get install python3-all returns the same error as earlier - E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution), and also lists a few packages.

1 Answers1

0

remove the libraries that came along with python using,

sudo apt autoremove

then update,

 sudo apt update

then install python by,

sudo apt-get install python2.7
  • It looks like no such operations - install/remove/reinstall, etc are going through. They all come up with the same error of unmet dependencies and ask me to use apt --fix-broken install. – rohitma38 Oct 10 '19 at 07:28