1

I was banging my head off the wall trying to change the path of pip install on my Ubuntu install. I guessed that it may have been the number of Python installations on my machine. I ended up accidentally deleting python and python3 from /usr/bin/.

Now nothing works. Both apt-get and sudo no longer work. Every command I run, I get the same output:

-bash: /usr/lib/command-not-found: /usr/bin/python3: bad interpreter: No such file or directory

I deleted the contents of /home/ubuntu/usr/bin. I was able to re-create that folder and I copied the files from /root/usr/bin/. I have also copied python3 and python into /home/ubuntu/usr/bin.

I am still getting the error:

-bash: /usr/lib/command-not-found: /usr/bin/python3: bad interpreter: No such file or directory

I am honestly navigating in the dark, any help would greatly appreciated.

Grammargeek
  • 2,762
  • 2
  • 14
  • 24
Murcielago
  • 121
  • 5
  • 1
    Did you remove the *packages*, or just delete the (symbolic links) `/usr/bin/python` and/or `/usr/bin/python3`? If the latter, it should be a simple matter of recreating the symlinks. If you need help with that, please [edit] your question to include the output of `ls -ld /usr/bin/python[23].[0-9]` – steeldriver Jan 21 '21 at 22:09
  • I still have the packages. I removed the symlinks I guess (there where red highlighted! I have deleted usr/bin/ directory. How would I got about recovering the symlinks? – Murcielago Jan 21 '21 at 22:14
  • Does this answer your question? [Updates stopped and fix-broken install is broken](https://askubuntu.com/questions/1304915/updates-stopped-and-fix-broken-install-is-broken) – Raffa Jan 21 '21 at 22:31
  • no, I don't think I can restore with a USB drive, my machine is linked to aws EC2 instance – Murcielago Jan 21 '21 at 22:37
  • If you deleted the *whole* `/usr/bin` directory, then you will have a lot more issues than just python unfortunately – steeldriver Jan 21 '21 at 23:18
  • so I think I am lucky that I have deleted what was inside of /home/ubuntu/usr/bin which didnt contain much things, I was a able to recreate a bin directory and I copy what was in root/usr/bin. I copied python 3 and python3.6 without success – Murcielago Jan 21 '21 at 23:27
  • Does this answer your question? [Removed Python 3 and now Ubuntu Software Center, terminal and other applications don't work](https://askubuntu.com/questions/384033/removed-python-3-and-now-ubuntu-software-center-terminal-and-other-applications) – karel Jan 22 '21 at 06:46

1 Answers1

1

You're likely running into issues with Ubuntu's "Command not found, did you mean [X]?" feature, which I believe is written in Python which would explain the issue you're facing.

Something you can try is changing your terminal's shell to /bin/sh, which shouldn't have the issue (because it doesn't load profiles). From this point you should be able to fix your system and get Python installed again.

Grammargeek
  • 2,762
  • 2
  • 14
  • 24